lizmat / CLI-Help

Add -h / --help parameters to your script
Artistic License 2.0
2 stars 1 forks source link

Need a working usage example #1

Open melezhik opened 2 years ago

melezhik commented 2 years ago

Hi! I am trying to use the documentation to create some working code, but does not produce any "help" documentation, this is what I get in my tomty test:

[task run: task.bash - .tomty/tasks/cli-help]
[dump code: task.bash]
[1] cat << 'JSON' > $cache_dir/META6.json
[2] {
[3]   "description" : "test test test",
[4]   "name" : "TestFoo",
[5]   "provides" : {
[6]     "TestFoo" : "lib/TestFoo.rakumod"
[7]   },
[8]   "resources" : [
[9]     "help.txt"
[10]   ],
[11]   "version" : "0.0.2"
[12] }
[13] JSON
[14] 
[15] mkdir $cache_dir/lib/
[16] 
[17] echo << 'HERE' > $cache_dir/lib/TestFoo.rakumod
[18] 
[19] proto sub MAIN(|) {*}
[20] 
[21] sub handler($text, @subsections, :$verbose) {
[22] 
[23]     my $SCRIPT := $*PROGRAM.basename;
[24]     my $header := "$SCRIPT - " ~ DESCRIPTION;
[25]     say $header;
[26]     say "-" x $header.chars;
[27] 
[28] 
[29] }
[30] 
[31] use CLI::Help:ver<0.0.2>:auth<zef:lizmat>    %?RESOURCES,    &MAIN, &HELP;
[32] 
[33] my multi sub MAIN(*@specs, *%n) {
[34]   say "hello!"
[35] }
[36] 
[37] 
[38] =begin pod
[39] 
[40] =head1 NAME
[41] 
[42] App::Rak - a CLI for searching strings in files and more
[43] 
[44] =end pod
[45] 
[46] HERE
[47] 
[48] mkdir $cache_dir/resources
[49] 
[50] echo "OK" > $cache_dir/resources/help.txt
[51] 
[52] mkdir $cache_dir/bin/
[53] 
[54] cat << 'HERE' > $cache_dir/bin/testfoo.raku
[55] 
[56] #my %*SUB-MAIN-OPTS = :named-anywhere;
[57] 
[58] use TestFoo;
[59] 
[60] HERE
[61] 
[62] zef install --force-install $cache_dir/ 2>&1
[63] 
[64] echo "==="
[65] 
[66] set -x
[67] 
[68] testfoo.raku --help  2>&1
[69] 
[task stdout]
20:43:28 :: ===> Testing: TestFoo:ver<0.0.2>
20:43:28 :: ===> Testing [OK] for TestFoo:ver<0.0.2>
20:43:28 :: ===> Installing: TestFoo:ver<0.0.2>
20:43:28 :: 
20:43:28 :: 1 bin/ script [testfoo.raku] installed to:
20:43:28 :: /Users/melezhik/.rakubrew/versions/moar-2022.06/share/perl6/site/bin
20:43:28 :: ===
[task stderr]
20:43:29 :: ++ testfoo.raku --help
melezhik commented 2 years ago

so, the last command testfoo.raku --help does not produce any output ... 🤔

lizmat commented 2 years ago

CLI::Help provides just the skeleton. You need to provide the actual help text in the resources of a module. See (incomplete) example at https://github.com/lizmat/App-Rak/tree/main/resources

melezhik commented 2 years ago

I do, please see echo "OK" > $cache_dir/resources/help.txt line in my test script

melezhik commented 2 years ago

also $cache_dir/META6.json contains :

"resources" : [
 "help.txt"
]
tbrowder commented 2 years ago

I, normally a non-MAIN-using person, would really appreciate a real simple, but complete, example.

melezhik commented 2 years ago

I reformated report for my previous test ( I did not manage to add --help to my code ) - https://gistcdn.githack.com/melezhik/7b323ef7975bc68d869730ee674db885/raw/013ba03a292e65e56e23e70e2b5fab1e629e7172/report.html