Skip to content

Commit

Permalink
feat(commands): add descriptions & usage notes
Browse files Browse the repository at this point in the history
  • Loading branch information
devnote-dev committed Sep 30, 2024
1 parent b43509e commit 03b2a53
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 15 deletions.
34 changes: 26 additions & 8 deletions src/commands/bisect.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,34 @@ module Crimson::Commands
class Bisect < Base
def setup : Nil
@name = "bisect"
@summary = "test installed Crystal versions"
@description = <<-DESC
Tests a given command over a set of specified versions. By default this command
will test all installed versions from the latest descending, but you can change
this by specifying the '--order' flag which accepts asc(ending), desc(ending)
and rand(om).
If you only want to test a subset of versions then you can specify the '--from'
flag with a version to start from and/or the '--to' flag with a version to stop
at.
The command will complete when all selected versions are tested, but this can be
changed to stop at the first failure by specifying the '--fail-first' flag. The
output from each version will be printed after all selected versions are tested
unless the '--progress' flag is specified, in which case the output is printed
after each version has been tested.
DESC

add_alias "bi"
add_usage "bisect [-F|--fail-first] [--from <version>] [-o|--order <asc|desc|random>] [--to <version>] <args>"

add_argument "args", multiple: true, required: true
add_option 'F', "fail-first"
add_option 'o', "order", type: :single
add_option "from", type: :single
add_option "to", type: :single
add_option 'p', "progress"
add_usage "bisect [-F|--fail-first] [-o|--order <asc|desc|random>] [--from <version>]" \
"\n\t[--to <version>] [-p|--progress] <args>"

add_argument "args", description: "the command to test", multiple: true, required: true
add_option 'F', "fail-first", description: "exit early at the first failed test"
add_option 'o', "order", description: "the order to execute versions in", type: :single
add_option "from", description: "the version to start testing from", type: :single
add_option "to", description: "the version to stop testing at", type: :single
add_option 'p', "progress", description: "print output after each test"
end

def pre_run(arguments : Cling::Arguments, options : Cling::Options) : Nil
Expand Down
34 changes: 27 additions & 7 deletions src/commands/import.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,33 @@ module Crimson::Commands
class Import < Base
def setup : Nil
@name = "import"

add_argument "path", required: true
add_option 'a', "alias", type: :single
add_option 'd', "default"
add_option "link"
add_option 's', "switch"
add_option 'R', "rename", type: :single
@summary = "import a local Crystal compiler"
@description = <<-DESC
Imports a local Crystal compiler from the file system at a given directory path.
Note that this command DOES NOT build the compiler at the given path, you should
compile Crystal before importing with Crimson. The 'bin', 'lib' and 'src'
directories are expected to be available in order to import the compiler.
The install version is obtained from the compiler during the import process.
Crimson will not import a compiler with a conflicting installed version. To
get around this you can specify the '--rename' flag with a version name to be
imported under.
By default all source files are copied from the directory path to the
destination path, but they can also be symlinked by specifying the '--link'
flag.
DESC

add_usage "import [-a|--alias <name>] [-d|--default] [--link] [-s|--switch]" \
"\n\t[-R|--rename <version>] <path>"

add_argument "path", description: "the path to the compiler", required: true
add_option 'a', "alias", description: "set the alias of the version", type: :single
add_option 'd', "default", description: "set the version as default"
add_option "link", description: "link source files to destination"
add_option 's', "switch", description: "switch the available version on the system"
add_option 'R', "rename", description: "set an alternative version name", type: :single
end

def run(arguments : Cling::Arguments, options : Cling::Options) : Nil
Expand Down

0 comments on commit 03b2a53

Please sign in to comment.