manojlds/cmd

Question

Opened this issue · 6 comments

What happens if someone wants to use one cmd instance twice, like
Cmd.dir(s:true)();
Cmd.type("my file.txt")();

I would recommend to return new object instead of this, and make it a combination of the current object and arguments. This will also allow partial specification objects, like

Var gitpull = cmd.git.pull;
gitpull("./")();

Idea on arguments vs invocation: indexers

Cmd.dir.s[true].order["name"]();
Cmd.type("myfile.txt"); // executes without another()

Yes, returning new object is definitley on the cards. Nice idea on the indexers. Would love pull request too :)

You can now run multiple commands on a single instance of cmd.

I am still thinking if the below scenario should be allowed:

var git = cmd.git;
git.clone();
git.branch(a: true);

Currently, the above will not work, as the git will be a single object.

I would suggest to make the cmd class immutable, and every time you access
a member (of root or member object), instead of modifying the instance, you
create and return a new instance, just like string class behaves.
to avoid copying command list you might store parent reference, and build
the list from parent chain at execution time.

On Mon, Dec 10, 2012 at 11:04 AM, Manoj notifications@github.com wrote:

You can now run multiple commands on a single instance of cmd.

I am still thinking if the below scenario should be allowed:

var git = cmd.git;git.clone();git.branch(a: true);

Currently, the above will not work, as the git will be a single object.


Reply to this email directly or view it on GitHubhttps://github.com//issues/2#issuecomment-11212147.

cmd now returns an instance of another object.

For example, cmd.git returns a new object ( of different ) type

cmd is effectively "immutable", but yeah, I suppose it makes sense to create new objects on each command?

Yes, I mean that instead of having "commando" object you might return a new
cmd object.

On Mon, Dec 10, 2012 at 11:29 AM, Manoj notifications@github.com wrote:

cmd now returns an instance of another object.

For example, cmd.git returns a new object ( of different ) type

cmd is effectively "immutable", but yeah, I suppose it makes sense to
create new objects on each command?


Reply to this email directly or view it on GitHubhttps://github.com//issues/2#issuecomment-11213263.