Nesting Commands

24 views
Skip to first unread message

Harsh Kumar

unread,
Apr 19, 2013, 5:53:44 AM4/19/13
to crash...@googlegroups.com
Hi

I wanted to know whether it is possible to nest commands in groovy.

Something like

parentcommand command1 arg1 command2 arg2

What i want is that after entering arg1 if i press tab then i should see command1 and 2 again as suboptions.

Any idea?

Julien Viet

unread,
Apr 19, 2013, 6:10:35 AM4/19/13
to crash...@googlegroups.com
you cannot do that. only a first sub command is possible (parentcommans command1 arg1)

what is your use case ?

--
Vous recevez ce message, car vous êtes abonné au groupe Google Groupes CRaSH User Group.
Pour vous désabonner de ce groupe et ne plus recevoir d'e-mails le concernant, envoyez un e-mail à l'adresse crash-users...@googlegroups.com.
Pour plus d'options, visitez le site https://groups.google.com/groups/opt_out .
 
 

Harsh Kumar

unread,
Apr 24, 2013, 5:55:36 AM4/24/13
to crash...@googlegroups.com
Hi,

My use case is as follows

Consider the following hierarchy

Bird
->Speed
->Height

Deer
->Speed

so in the CLI say crash%

e.g.

crash% [Press tab]
bird deer
crash% bird [Press tab]
speed (mandatory) height (default 40)
crash% bird speed 30 height 40
Output->Bird is flying at a speed of 30m/s at a height of 40m


Can you make any sense of it? Any help would be appreciated



--
Vous recevez ce message car vous êtes abonné à un sujet dans le groupe Google Groupes "CRaSH User Group".
Pour vous désabonner de ce sujet, visitez le site https://groups.google.com/d/topic/crash-users/fIxOy1J8Irg/unsubscribe?hl=fr.
Pour vous désabonner de ce groupe et de tous ses sujets, envoyez un e-mail à l'adresse crash-users...@googlegroups.com.

Pour plus d'options, visitez le site https://groups.google.com/groups/opt_out .
 
 



--
Sincerely
Harsh Kumar
-------------------------------------------------------------------------------------------------------------------
Please consider the environment before printing this email.
Please do not print this email unless it is absolutely necessary.

The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments.

WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. I accept no liability for any damage caused by any virus transmitted by this email.
-------------------------------------------------------------------------------------------------------------------

Julien Viet

unread,
Apr 24, 2013, 9:31:53 AM4/24/13
to crash...@googlegroups.com
what does not make sense is to provide (mandatory) and (default 40) in the completion because the suggested value will be selected when there is only one choice.

the concept of several level of nesting can be emulated using arguments instead of functions, I come up with this solution:


give a try and let me know what you think of it

Harsh Kumar

unread,
Apr 26, 2013, 2:48:37 AM4/26/13
to crash...@googlegroups.com
Hi,

This looks promising. But is there a way I can have multiple attributes displayed on pressing tab. Basically a usage or -h option by default, I am extending the existing example here only.


Bird
->Speed
->Height [40]
->Distance

crash% bird [Press tab]
speed height[40] distance

crash% bird speed 30 [Press Tab]
height[40] distance

crash% bird speed 30
crash% bird speed 30 d[Press Tab] -> should expand it to %bird distance OR
crash% bird speed 30 h[Press Tab] -> should expand it to %bird height
crash% bird speed 30 distance 40 [Press Enter]

Output->Bird is flying at a default speed of 30m/s at a default height of 40m and has travelled 40 meters


I really appreciate your proactive help on the usage of crash. Thanks a million

Julien Viet

unread,
Apr 27, 2013, 9:27:06 AM4/27/13
to crash...@googlegroups.com
there are two issues that prevent that :

1/ when there is a single completion then this completion is often selected by the client so having the completion "speed height[40] distance" will complete directly the command line and not propose a guess so if you do:

% bird [Press tab]
and the command returns "speed height[40] distance"

then the shell will react as:

% bird speed height[40] distance

2/ spaces will be escaped with \ because it is considered as a single value, so it would be "speed\ height[40]\ distance"

Harsh Kumar

unread,
Apr 28, 2013, 12:33:11 AM4/28/13
to crash...@googlegroups.com
Thanks a lot Julien. I think I can work with whatever your have suggested. Thanks a million. 
Reply all
Reply to author
Forward
0 new messages