![]() | Parsing args in GLI |
|
17 Feb 2012, 14:22
Taro Fukunaga (8 posts) |
Hi, I’m trying to rewrite my option parser app in GLI and I’m not sure how to do it. What I want for the user to type is: sysinfo get cpu In the generated scaffold code I tried adding the following: c.desc ‘Get CPU info But I’m not sure how to check whether this argument was passed. I tried this in the c.action block: if args == “cpu”
puts ‘cpu’ But nothing is printed. |
|
17 Feb 2012, 15:43
David Copeland (85 posts) |
It looks like you’re wanting a multi-level command suite. GLI doesn’t support this directly (though it’s planned for GLI 2.0), but you could do it like so:
And similar for Another option would be to make your commands like |
|
17 Feb 2012, 16:35
Taro Fukunaga (8 posts) |
David, thank you very much for a quick reply. I’ll explore these two options. |
|
07 Dec 2012, 05:33
Dennis Sutch (8 posts) |
Does GLI 2.5 support multi-level command suites? If so, are any examples on how to use this feature available? |
|
08 Dec 2012, 00:31
David Copeland (85 posts) |
Yes! GLI2 does support what you are trying to do. You basically nest |
|
01 Jan 2013, 02:21
Dennis Sutch (8 posts) |
Thanks for the helpful documentation. Nested command blocks work as advertised. |
| You must be logged in to comment |

