Click makes python attractive for CLI's. It is far better than bash and perl for simple stuff. Fire looks useful for hacks but Click has been excellently intuitive for me.
cat > cli.pl6
#| Duplicates without frobnication
multi sub MAIN( 'duplicate', Int $times, Str $text ) {
say $text x $times;
}
#| Frobnicates up to a limit
multi sub MAIN('frobnicate', Int :$length = 24, Bool :v(:$verbose))
{
say 'Verbosity ', ($verbose ?? 'on' !! 'off');
}
perl6 cli.pl
Usage:
cli.pl6 duplicate <times> <text> -- Duplicates without frobnication
cli.pl6 [--length=<Int>] [-v|--verbose] frobnicate -- Frobnicates up to a limit
perl6 cli.pl6 duplicate 3 blah...
blah...blah...blah...Here's a decent example of this https://github.com/pytorch/examples/blob/master/imagenet/mai...
def train(
data: File,
arch='resnet18',
workers=4,
epochs=90,
start_epoch=0,
batch_size=256,
learning_rate=0.9,
momentum=1e-4,
):
...
that could be exposed as a cli if __name__ is main but otherwise can be imported in a notebook or another script.