perlpunk / app-spec-p5 Goto Github PK
View Code? Open in Web Editor NEWWriting command line apps made easy
License: Other
Writing command line apps made easy
License: Other
Looking at the source code, I notice that in a few places you're not exploiting the facilities that Moo
provides (e.g. you've got common
and build
do more-or-less what BUILDARGS
and BUILD
are designed to do, you handle lazy attributes by hand, you have no type constraints).
Is there a particular reason for that, or is just general unfamiliarity with Moo
?
Would it be appreciated if I sent a pull request making the whole thing more Moo-ish? I'd also like to add some type constraints via Type::Tiny
, but that can come later.
I don't see the need for YAML.
It would be much simpler to write the spec in Perl.
If you had the need to parse the spec from outside the program itself (ex for documentation generators), you could just inject an --export-getopt-spec
option that would dump the spec.
Rename App::Spec::Completion::Bash
to App::Spec::Completion::bash
and App::Spec::Completion::Zsh
to App::Spec::Completion::zsh
.
That will allow extension and simplify App::Spec::generate_completion
:
sub generate_completion {
my ($self, %args) = @_;
my $shell = delete $args{shell};
require "App/Spec/Completion/$shell.pm";
"App::Spec::Completion::$shell"->new({ spec => $self })->generate_completion(%args)
}
If you have a dynamic completion which fetches values from a HTTP request, for example, that could take a while.
Allow caching of the values in the current shell session.
Before 0.005, it was possible to ignore the class
slot of the spec, as long as a pre-built object was set in App::Spec::Run::cmd
.
Now, op method names are assumed to be fully-qualified, and if not, they're prefixed with the class. I'm not sure why this is.
Currently only apps with at least one subcommand level are possible.
Before 0.005, a command op could be a coderef, which was nice for those times where you just need to call an existing method with a value from the runner, see https://www.thenautilus.net/cgit/Sietima/tree/lib/Sietima/Role/SubscriberOnly/Moderate.pm?h=v1.0.4-dzilla&id=402b4b8e83babbb453c3caa23fb7e75c0cfbe1c0#n221for example.
With 0.005, I had to add methods just for App::Spec, see
https://www.thenautilus.net/cgit/Sietima/commit/?id=db2394b8c0beba5f4323dffe2d20adad1c5acf2b
Generating a man pages (or several per subcommand) from your spec with the complete usage and descriptions.
Generating a pod file from your spec with the complete usage and descriptions.
myapp command --file foo.txt --file boo.txt
Right now only parameters for apps with subcommands are possible, and for nested subcommands only for the last subcommand.
Todo:
myapp param [options]
myapp param0 cmd1 param1 cmd2 param2 [options]
Possibility to define when an option is used another option is required, or if an option has a certain value another option gets a certain default value.
I don't know how to install this great module, I love the ideas implemented here!
In fact I have the feeling there is nothing like 'perl Makefile.PL; make; make install'. Is the idea for development-time simply to copy lib/App to my current directory und do this:
use lib './lib';
use App::Spec;
...
I wish it would be more fun if I could do it the perl-standard way:
git clone https://github.com/perlpunk/App-Spec-p5.git
cd App-Spec-p5
perl Makefile.PL
make
make install
Thanks for your understanding.
Richard
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.