Hi,

On Fri, May 10, 2013 at 10:38 AM, Afkham Azeez <az...@wso2.com> wrote:

>
>
> On Fri, May 10, 2013 at 10:37 AM, Afkham Azeez <az...@wso2.com> wrote:
>
>>
>>
>> On Fri, May 10, 2013 at 2:24 AM, Paul Fremantle <p...@wso2.com> wrote:
>>
>>> +1. But let's do that beyond S2 release.
>>>
>>
>> I agree. What I wanted to say is, while developing this CLI tool, if you
>> use proper abstractions from the outset, so  that it is not tightly coupled
>> to Stratos 2, we will require less effort when making it into a generic
>> tool.
>>
>
> IsuruP brought up the concept of programming to the interface on a
> different thread sometime back. So, we could follow the same here to make
> life easier in the future.
>
Yes. We can adopt similar design.

For this, we need to decide on which libraries to use.

For command line argument parsing, we can use Apache Commons CLI [1] or
JCommander [2]

For handling console input, jline [3] and jline2 [4] libraries are used in
many projects. For example, java-cli-api [5] & Spring Shell [6].

jline2 is the newer version and therefore I think we can use that.

[1] http://commons.apache.org/proper/commons-cli/
[2] http://jcommander.org/
[3] http://jline.sourceforge.net/
[4] http://jline.github.io/jline2/
[5] http://code.google.com/p/java-cli-api/
[6] http://www.springsource.org/spring-shell


>
>>
>>> Paul
>>>
>>>
>>> On 9 May 2013 21:51, Afkham Azeez <az...@wso2.com> wrote:
>>>
>>>> It would be good if you could make this a generic CLI tooling framework
>>>> for Carbon. We need it not only in Stratos 2, but in many other areas. We
>>>> can provide CLI tooling to deploy artifacts into a server, for example.
>>>>
>>>> On Fri, May 10, 2013 at 1:23 AM, Isuru Perera <isu...@wso2.com> wrote:
>>>>
>>>>>  Hi,
>>>>>
>>>>> For Stratos 2.0 release, we are planning to improve the existing CLI
>>>>> Tool [1].
>>>>>
>>>>> We are planning to support following features in Stratos2 CLI Tool
>>>>>
>>>>>
>>>>>    - Command history [2]
>>>>>    - Auto-completion of commands
>>>>>    - Character masking (for passwords) [3]
>>>>>
>>>>>
>>>>> For above features, we are planning to use jline2 library [4].
>>>>>
>>>>> *Existing Design*
>>>>>
>>>>> Currently the CLI tool has two modes. (Stratos2 CLI source can be
>>>>> found at [5])
>>>>>
>>>>> 1. Interactive Mode - In this mode, user is logged in by passing only
>>>>> username & password as arguments.
>>>>>
>>>>> $stratos <username> <password>
>>>>> After successful login, the user get a prompt as "stratos>"
>>>>>
>>>>> 2. Single Command Line Mode - In this mode, all the commands are
>>>>> passed as arguments including username and password
>>>>>
>>>>> $stratos <username> <password> list
>>>>> This will list all the cartridges.
>>>>>
>>>>> AFAIK, we can support above features only when the CLI tool is in
>>>>> prompt mode. In order to provide auto-complete features at the terminal, 
>>>>> we
>>>>> need to use OS specific functions, for example /etc/bash_completion [6]
>>>>>
>>>>> *Drawbacks of existing Beta 2 CLI Tool & Possible Solutions*
>>>>>
>>>>> 1. A drawback of existing design is that we have to login every time
>>>>> the stratos command is executed.
>>>>>
>>>>> Solution: Login only once. The back-end service is an admin service
>>>>> and we login as a tenant. I'm thinking of a way to save session in the 
>>>>> file
>>>>> system. For example inside <user.home>/.stratos/
>>>>>
>>>>> If we can save the session id, then we use the same for authenticate
>>>>> next requests. In this way, the user can use the CLI tool, until the
>>>>> session times out.
>>>>>
>>>>> Or else we can keep the username and password cached (encrypted form).
>>>>> In this way, user can keep using the tool without worrying about the
>>>>> session time out.
>>>>>
>>>>> Which is the better way?
>>>>>
>>>>> 2. Currently the password is entered in the command line itself
>>>>>
>>>>> Solution: With jline2, we can use masking for password input.
>>>>>
>>>>> 3. Command history not support.
>>>>>
>>>>> Solution: jline2 can provide command history. Additionally if we can
>>>>> login only once, user can execute commands directly in terminal and use 
>>>>> the
>>>>> history available in the terminal environment.
>>>>>
>>>>> *New Design*
>>>>>
>>>>> I'm going to introduce following commands to the tool
>>>>>
>>>>> 1. $stratos setup
>>>>> This will prompt for Stratos Controller hostname & port. These values
>>>>> will be saved in <user.home>/.stratos/stratos.config
>>>>>
>>>>> 2. $stratos login
>>>>> This will have arguments for username and password. Password will be
>>>>> prompted with masked character. Authentication details will be saved in
>>>>> <user.home>/.stratos/
>>>>>
>>>>> 3. $stratos logout
>>>>> Logout user.
>>>>>
>>>>> After successful login, user can go into interactive mode by just
>>>>> entering "stratos" or user can execute commands in single line. For 
>>>>> example
>>>>> "stratos list", "stratos subscribe" etc.
>>>>>
>>>>> CLI Tool will also be improved to use a single '-' for short option
>>>>> names and '--' for longer option names [7].
>>>>>
>>>>> WDYT?
>>>>>
>>>>> [1] https://wso2.org/jira/browse/SPI-234
>>>>> [2] https://wso2.org/jira/browse/SPI-111
>>>>> [3] https://wso2.org/jira/browse/SPI-241
>>>>> [4] http://jline.github.io/jline2/
>>>>> [5]
>>>>> https://svn.wso2.org/repos/wso2/carbon/platform/branches/4.1.0/components/stratos/artifact-deployment-coordinator/org.wso2.carbon.adc.mgt.cli/2.1.1
>>>>> [6] http://www.debian-administration.org/articles/316
>>>>> [7] https://wso2.org/jira/browse/SPI-240
>>>>>
>>>>> --
>>>>> Isuru Perera
>>>>> Senior Software Engineer | WSO2, Inc. | http://wso2.com/
>>>>> Lean . Enterprise . Middleware
>>>>>
>>>>> Twitter: http://twitter.com/chrishantha | LinkedIn:
>>>>> http://lk.linkedin.com/in/chrishantha/
>>>>>
>>>>> _______________________________________________
>>>>> Architecture mailing list
>>>>> Architecture@wso2.org
>>>>> https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> *Afkham Azeez*
>>>> Director of Architecture; WSO2, Inc.; http://wso2.com
>>>> Member; Apache Software Foundation; http://www.apache.org/
>>>> * <http://www.apache.org/>**
>>>> email: **az...@wso2.com* <az...@wso2.com>* cell: +94 77 3320919
>>>> blog: **http://blog.afkham.org* <http://blog.afkham.org>*
>>>> twitter: 
>>>> **http://twitter.com/afkham_azeez*<http://twitter.com/afkham_azeez>
>>>> *
>>>> linked-in: **http://lk.linkedin.com/in/afkhamazeez*
>>>>
>>>> *
>>>> *
>>>> *Lean . Enterprise . Middleware*
>>>>
>>>> _______________________________________________
>>>> Architecture mailing list
>>>> Architecture@wso2.org
>>>> https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture
>>>>
>>>>
>>>
>>>
>>> --
>>> Paul Fremantle
>>> CTO and Co-Founder, WSO2
>>> OASIS WS-RX TC Co-chair, VP, Apache Synapse
>>>
>>> UK: +44 207 096 0336
>>> US: +1 646 595 7614
>>>
>>> blog: http://pzf.fremantle.org
>>> twitter.com/pzfreo
>>> p...@wso2.com
>>>
>>> wso2.com Lean Enterprise Middleware
>>>
>>> Disclaimer: This communication may contain privileged or other
>>> confidential information and is intended exclusively for the addressee/s.
>>> If you are not the intended recipient/s, or believe that you may have
>>> received this communication in error, please reply to the sender indicating
>>> that fact and delete the copy you received and in addition, you should not
>>> print, copy, retransmit, disseminate, or otherwise use the information
>>> contained in this communication. Internet communications cannot be
>>> guaranteed to be timely, secure, error or virus-free. The sender does not
>>> accept liability for any errors or omissions.
>>>
>>> _______________________________________________
>>> Architecture mailing list
>>> Architecture@wso2.org
>>> https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture
>>>
>>>
>>
>>
>> --
>> *Afkham Azeez*
>> Director of Architecture; WSO2, Inc.; http://wso2.com
>> Member; Apache Software Foundation; http://www.apache.org/
>> * <http://www.apache.org/>**
>> email: **az...@wso2.com* <az...@wso2.com>* cell: +94 77 3320919
>> blog: **http://blog.afkham.org* <http://blog.afkham.org>*
>> twitter: **http://twitter.com/afkham_azeez*<http://twitter.com/afkham_azeez>
>> *
>> linked-in: **http://lk.linkedin.com/in/afkhamazeez*
>> *
>> *
>> *Lean . Enterprise . Middleware*
>>
>
>
>
> --
> *Afkham Azeez*
> Director of Architecture; WSO2, Inc.; http://wso2.com
> Member; Apache Software Foundation; http://www.apache.org/
> * <http://www.apache.org/>**
> email: **az...@wso2.com* <az...@wso2.com>* cell: +94 77 3320919
> blog: **http://blog.afkham.org* <http://blog.afkham.org>*
> twitter: **http://twitter.com/afkham_azeez*<http://twitter.com/afkham_azeez>
> *
> linked-in: **http://lk.linkedin.com/in/afkhamazeez*
> *
> *
> *Lean . Enterprise . Middleware*
>
> _______________________________________________
> Architecture mailing list
> Architecture@wso2.org
> https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture
>
>


-- 
Isuru Perera
Senior Software Engineer | WSO2, Inc. | http://wso2.com/
Lean . Enterprise . Middleware

Twitter: http://twitter.com/chrishantha | LinkedIn:
http://lk.linkedin.com/in/chrishantha/
_______________________________________________
Architecture mailing list
Architecture@wso2.org
https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture

Reply via email to