diff --git a/src/nimble.nim b/src/nimble.nim index 9437627a..720780bf 100644 --- a/src/nimble.nim +++ b/src/nimble.nim @@ -1,7 +1,7 @@ # Copyright (C) Dominik Picheta. All rights reserved. # BSD License. Look at license.txt for more info. -import os, tables, strtabs, json, algorithm, sets, uri, sugar, sequtils, osproc, +import os, tables, strtabs, json, browsers, algorithm, sets, uri, sugar, sequtils, osproc, strformat import std/options as std_opt @@ -2275,6 +2275,14 @@ proc run(options: Options) = let exitCode = cmd.execCmd raise nimbleQuit(exitCode) +proc openNimbleManual = + const NimbleGuideURL = "https://nim-lang.github.io/nimble/index.html" + display( + "Opened", "the Nimble guide in your default browser." + ) + displayInfo("If it did not open, you can try going to the link manually: " & NimbleGuideURL) + openDefaultBrowser(NimbleGuideURL) + proc doAction(options: var Options) = if options.showHelp: writeHelp() @@ -2347,6 +2355,8 @@ proc doAction(options: var Options) = assert false of actionAdd: addPackages(options.action.packages, options) + of actionManual: + openNimbleManual() of actionCustom: var optsCopy = options optsCopy.task = options.action.command.normalize diff --git a/src/nimblepkg/options.nim b/src/nimblepkg/options.nim index 7119e94a..4dab9321 100644 --- a/src/nimblepkg/options.nim +++ b/src/nimblepkg/options.nim @@ -70,7 +70,7 @@ type actionInstall, actionSearch, actionList, actionBuild, actionPath, actionUninstall, actionCompile, actionDoc, actionCustom, actionTasks, actionDevelop, actionCheck, actionLock, actionRun, actionSync, actionSetup, - actionClean, actionDeps, actionShellEnv, actionShell, actionAdd + actionClean, actionDeps, actionShellEnv, actionShell, actionAdd, actionManual DevelopActionType* = enum datAdd, datRemoveByPath, datRemoveByName, datInclude, datExclude @@ -80,7 +80,7 @@ type Action* = object case typ*: ActionType of actionNil, actionList, actionPublish, actionTasks, actionCheck, - actionSetup, actionClean: nil + actionSetup, actionClean, actionManual: nil of actionSync: listOnly*: bool of actionRefresh: @@ -339,6 +339,8 @@ proc parseActionType*(action: string): ActionType = result = actionShell of "add": result = actionAdd + of "manual", "guide": + result = actionManual else: result = actionCustom @@ -918,4 +920,4 @@ proc isSubdirOf*(subdir, baseDir: string): bool = when defined(windows): normalizedSubdir.toLower.startsWith(normalizedBaseDir.toLower) else: - normalizedSubdir.startsWith(normalizedBaseDir) \ No newline at end of file + normalizedSubdir.startsWith(normalizedBaseDir)