Skip to content

Commit

Permalink
Use system.program-name. (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
floitsch authored Jan 18, 2024
1 parent 31f4cc2 commit 6fdcf3b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ jobs:
os: [ ubuntu-latest, windows-latest, macos-latest ]
# The versions should contain (at least) the lowest requirement
# and a version that is more up to date.
toit-version: [ v2.0.0-alpha.120, latest ]
toit-version: [ v2.0.0-alpha.128, latest ]
include:
- toit-version: v2.0.0-alpha.120
- toit-version: v2.0.0-alpha.128
version-name: old
- toit-version: latest
version-name: new
Expand Down
2 changes: 1 addition & 1 deletion package.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: cli
description: Tools, like an argument parser, to create command-line applications.
environment:
sdk: ^2.0.0-alpha.120
sdk: ^2.0.0-alpha.128
dependencies:
fs:
url: github.com/toitlang/pkg-fs
Expand Down
11 changes: 6 additions & 5 deletions src/cli.toit
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// found in the package's LICENSE file.
import uuid
import system

import .parser_
import .utils_
Expand Down Expand Up @@ -157,13 +158,13 @@ class Command:
subcommands_.add command

/** Returns the help string of this command. */
help --invoked-command/string=program-name -> string:
help --invoked-command/string=system.program-name -> string:
generator := HelpGenerator [this] --invoked-command=invoked-command
generator.build-all
return generator.to-string

/** Returns the usage string of this command. */
usage --invoked-command/string=program-name -> string:
usage --invoked-command/string=system.program-name -> string:
generator := HelpGenerator [this] --invoked-command=invoked-command
generator.build-usage --as-section=false
return generator.to-string
Expand All @@ -175,19 +176,19 @@ class Command:
with the $Parsed output.
The $invoked-command is used only for the usage message in case of an
error. It defaults to $program-name.
error. It defaults to $system.program-name.
The default $ui prints to stdout and calls `exit 1` when $Ui.abort is called.
*/
run arguments/List --invoked-command=program-name --ui/Ui=Ui_ -> none:
run arguments/List --invoked-command=system.program-name --ui/Ui=Ui_ -> none:
parser := Parser_ --ui=ui --invoked-command=invoked-command
parsed := parser.parse this arguments
parsed.command.run-callback_.call parsed

/**
Checks this command and all subcommands for errors.
*/
check --invoked-command=program-name:
check --invoked-command=system.program-name:
check_ --path=[invoked-command]

are-prefix-of-each-other_ str1/string str2/string -> bool:
Expand Down

0 comments on commit 6fdcf3b

Please sign in to comment.