Skip to content

Commit

Permalink
Merge pull request #64 from huantianad/main
Browse files Browse the repository at this point in the history
Add -v/--version, -h/--help description edit
  • Loading branch information
froehlichA committed Jan 13, 2022
2 parents b6cd21c + f75ae36 commit 4a41421
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
32 changes: 21 additions & 11 deletions src/pax.nim
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import therapist
import cmd/add, cmd/expo, cmd/impo, cmd/init, cmd/list, cmd/pin, cmd/remove, cmd/update, cmd/upgrade, cmd/version
import term/color, term/prompt
import util/paxVersion

let commonArgs = (
strategy: newStringArg(@["-s", "--strategy"],
Expand All @@ -13,6 +14,14 @@ let commonArgs = (
),
noColor: newCountArg(@["--no-color"],
help = "disable colored output"
),
# Version should only work with no subcommands
version: newMessageArg(@["-v", "--version"],
currentPaxVersion,
help = "show version information"
),
help: newHelpArg(@["-h", "--help"],
help = "show help message"
)
)

Expand All @@ -28,7 +37,7 @@ let initCmd = (
),
yes: commonArgs.yes,
noColor: commonArgs.noColor,
help: newHelpArg()
help: commonArgs.help
)

let listCmd = (
Expand All @@ -40,7 +49,7 @@ let listCmd = (
),
yes: commonArgs.yes,
noColor: commonArgs.noColor,
help: newHelpArg()
help: commonArgs.help
)

let addCmd = (
Expand All @@ -54,7 +63,7 @@ let addCmd = (
strategy: commonArgs.strategy,
yes: commonArgs.yes,
noColor: commonArgs.noColor,
help: newHelpArg()
help: commonArgs.help
)

let removeCmd = (
Expand All @@ -65,7 +74,7 @@ let removeCmd = (
strategy: commonArgs.strategy,
yes: commonArgs.yes,
noColor: commonArgs.noColor,
help: newHelpArg()
help: commonArgs.help
)

let pinCmd = (
Expand All @@ -75,7 +84,7 @@ let pinCmd = (
),
yes: commonArgs.yes,
noColor: commonArgs.noColor,
help: newHelpArg()
help: commonArgs.help
)

let updateCmd = (
Expand All @@ -86,14 +95,14 @@ let updateCmd = (
strategy: commonArgs.strategy,
yes: commonArgs.yes,
noColor: commonArgs.noColor,
help: newHelpArg()
help: commonArgs.help
)

let upgradeCmd = (
strategy: commonArgs.strategy,
yes: commonArgs.yes,
noColor: commonArgs.noColor,
help: newHelpArg()
help: commonArgs.help
)

let versionCmd = (
Expand All @@ -109,7 +118,7 @@ let versionCmd = (
),
yes: commonArgs.yes,
noColor: commonArgs.noColor,
help: newHelpArg()
help: commonArgs.help
)

let importCmd = (
Expand All @@ -124,7 +133,7 @@ let importCmd = (
),
yes: commonArgs.yes,
noColor: commonArgs.noColor,
help: newHelpArg()
help: commonArgs.help
)

let exportCmd = (
Expand All @@ -135,7 +144,7 @@ let exportCmd = (
),
yes: commonArgs.yes,
noColor: commonArgs.noColor,
help: newHelpArg()
help: commonArgs.help
)

let spec = (
Expand Down Expand Up @@ -181,7 +190,8 @@ let spec = (
),
yes: commonArgs.yes,
noColor: commonArgs.noColor,
help: newHelpArg()
paxVersion: commonArgs.version,
help: commonArgs.help
)

spec.parseOrHelp()
Expand Down
5 changes: 5 additions & 0 deletions src/util/paxVersion.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Helper file for retrieving pax version from latest tag

import strutils

const currentPaxVersion*: string = staticExec("git describe --tags HEAD").split("-")[0]

0 comments on commit 4a41421

Please sign in to comment.