Skip to content

Instantly share code, notes, and snippets.

@antoniogamiz
Created June 25, 2020 09:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antoniogamiz/3a824c2fd8d4727fa6340d2fabc6c05b to your computer and use it in GitHub Desktop.
Save antoniogamiz/3a824c2fd8d4727fa6340d2fabc6c05b to your computer and use it in GitHub Desktop.
use Test;
use Test::Output;
use File::Directory::Tree;
use CLI;
# you can comment one of the subtests block and it will still print the text.
subtest 'no arguments provided' => {
output-like {CLI::MAIN()}, /Execute/, "show help message";
}
subtest 'version command' => {
output-like {CLI::MAIN(:version)}, /Documentable\sversion/, "long version";
}
done-testing;
package CLI {
sub RUN-MAIN(|c) is export {
my %*SUB-MAIN-OPTS = :named-anywhere;
CORE::<&RUN-MAIN>(|c)
}
our proto MAIN(|) is export { * }
multi MAIN (
"setup",
Bool :y(:$yes) = False
) {
say "setup";
}
multi MAIN (
"start" ,
Str :$topdir = "doc",
Str :$conf = "config.json",
Bool :v(:verbose($v)) = False,
Bool :p(:primary($p)) = False,
Bool :s(:secondary($s)) = False,
Bool :$search-index = False,
Bool :i(:indexes($i)) = False,
Bool :t(:typegraph($t)) = False,
Bool :f(:force($f)) = False,
Bool :$highlight = False,
Str :$typegraph-file = "type-graph.txt",
Str :$highlight-path = "./highlights",
Str :$dirs?,
Bool :a(:$all) = False
) {
say "start";
}
multi MAIN (
"update",
Str :$topdir = "doc",
Str :$conf = "config.json",
Bool :v(:$verbose) = True ,
Bool :$highlight = False,
Str :$highlight-path = "./highlights"
) {}
multi MAIN (
"clean"
) {
say "clean";
}
multi MAIN (
Bool :V(:$version)!
) {
say "version";
}
multi MAIN() {
note 'Execute "documentable --help" for more information.';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment