now / ame Goto Github PK
View Code? Open in Web Editor NEWAme provides a simple command-line interface API for Ruby.
Home Page: http://disu.se/software/ame-1.0/
License: Other
Ame provides a simple command-line interface API for Ruby.
Home Page: http://disu.se/software/ame-1.0/
License: Other
One method should be able to get the options from another method so that it can easily call that method with the correct options. For example,
class T < Ame::Class
option 't'
option 'u'
def run(options)
…
end
options 'run' # or other method lookup spec, such as 'test:run'
option 'v'
def begin(options)
call 'run', nil, options if option['v']
end
end
The name of an Argument should be normalized as well, turning '_' into '-' for the user. This is true for Options and their aliases as well.
Currently arguments and a possible splat are handled completely separately. It would be very nice if one wouldn’t have to treat splat separately, it simply being the last yielded value from #each and such. This would require making #process compatible, perhaps by checking the argument’s arity and either passing by #shift or a whole array. The same goes for displaying them.
Should #parse perhaps take options and processed arguments? This could be used
by Ample::Ame::Types::Project to determine if we’re looking for a project or a
directory, depending on if we’ve seen -p or --projects.
Another solution would be to add a :disable option to options that would allow
an option to disable an array of other options, given as strings, for example
'--projects', and arguments, given as symbols, for example, :project. This
information could potentially be used to output multiple usage lines. One
thing that speaks against this is that its both complicated to deal with
(probably requiring Arguments to know about Options) and it’s not good UI
design. It’s better to have
% ramex extract-project 12345-01 12345-02
% ramex extract //Filer/Projects/12345/01/… //Filer/Projects/12345/01/…
than
% ramex extract --projects 12345-01 12345-02
% ramex extract //Filer/Projects/12345/01/… //Filer/Projects/12345/01/…
I mean, even though the actual help output might be slightly longer it’s
immediately obvious that there are two separate methods available and that they
do different things and how to use them.
Many current tools continue processing arguments even though some might fail.
Touch(1) touches arguments even though some might fail:
% touch a /no/such/directory b
touch: cannot touch `/uaua/ua': No such file or directory
Here, both “a” and “b” have been touched.
Help::Console.arguments should work like Help::Console.options and the current Help::Console.arguments should be renamed to Help::Console.usage_arguments.
All methods should take the 'help' option. Dispatch methods already do it, but action method don’t. It’s a simple matter of adding it to the constructor of Method. Then, whenever Method#call is invoked, check for options['help'] and, if present, use Help::Console (or whatever help utility has been selected) to display help for self, that is, the method.
Don’t apply initial capitalization of error messages.
They should obviously be defined on #initialize, but how exactly do we instantiate objects and call .new/#initialize?
Currently, any dispatches require the action argument. One way of supporting optional actions to a dispatch, thus making the dispatch itself a possible action, is to check if a method with the same name as the dispatch already exists on the class that’s gaining the dispatch. If so, unbind the method, mark 'action' as optional, and check whether 'action' is nil in the dispatch. If it is nil, then bind the method and call it.
Specifying a malformed argument to an option will report the name that the option was registered with, not the option the user actually used.
class B < A
end
calls .inherited before any .method_added, whereas
B = Class.new(A) do
end
calls .inherited when the block is finished. We need to remove inherited and only call it once #initialize has been defined.
Ame::Dispatch should deal with common options and dispatching on first argument.
Ame::Class.usage should return an array of usage examples that will have the program name and class name prefixed when printed. The first example will be prefixed by "Usage: " and the rest with " or: " when printed. This will require Ame::Help::Console to take the class as an argument to its constructor.
option 'version', :alias => 'v'
reads better than
option 'version', :aliases => 'v'
Lines wider than COLUMNS should be wrapped in the help output. They should be indented properly, too. This is quite complicated to get right, but worth it in the end.
Error out on extra arguments
Short options with arguments should be displayed as taking an argument in Ame::Help::Console. Curerntly, only “-X” is displayed for option “X”. It should be “-X=ARG”, if #argument_name is “ARG”.
This class will replace the Amplify utility. It should basically be a front-end to all tasks that deal with a package, such as testing, packaging, distribution, and so on.
To be able to output the usage of an Ame::Class it has to have a .description.
Perhaps one way of solving this is simply to instantiate new objects each time and remove the Singleton stuff. Options to #initialize can always be set on the class for defaults. There’s really no need to only have one instance. Perhaps remove the restricted invocation of methods and add a subclass that only executes once for make-like task methods.
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.