Hi,

On Fri, May 10, 2013 at 2:36 AM, Isuru Perera <[email protected]> wrote:

> Hi,
>
>
> On Fri, May 10, 2013 at 5:09 AM, Lahiru Sandaruwan <[email protected]>wrote:
>
>> Hi Isuru,
>>
>> +1 for the improvements.
>>
>> Find my comments inline
>>
>>
>> On Thu, May 9, 2013 at 9:53 PM, Isuru Perera <[email protected]> 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>"
>>>
>>
>> We gave up -u, -p for passing credentials as they were mandatory.
>> Since we are improving it to mask password its good to have the options
>> model back.
>>
> +1
>
>>
>> We used Apache commons cli library to achieve that as for all other
>> optional inouts. Same library may help to add it again if we continue to
>> use that library.
>>
> My current plan is to use Apache Commons CLI library as it is. It can be
> used to parse command line arguments. However I need to figure out how to
> use that library effectively in Interactive Mode. Currently, the CLI tool
> just uses string comparisons/manipulations  in the interactive mode [1]. I
> think we should improve that as well.
>

Both parsers use Commons library to parse options and string
manipulations/comparisons to parse mandatory inputs.

So it is kind of hybrid parser we implemented at the end.
AFAIR this library only support parsing options. That is a limitation it
has. So we might have to find another library(may be to parse both options
and mandatory inputs).

>
>
>>
>>> 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.
>>>
>> Normal command features are supported in this mode(e.g. History) as we
>> run them in terminal, not in an our prompt.
>>
> Yes. As I mentioned, we can use jline2 to provide above features in
> Interactive Mode. In single command line mode, we can use history in the
> terminal. Only problem is auto completing options.
>
+1

>
>>
>>> In order to provide auto-complete features at the terminal, we need to
>>> use OS specific functions, for example /etc/bash_completion [6]
>>>
>>>
>> The single line mode was introduced later for the requirement of
>> scripting Stratos commands.
>> Eg. To write a bash script to do any Stratos operations.
>> Make sure we have a way to achieve that with new improvements.
>>
> +1
>
> I will not change existing modes. i.e. Interactive Mode & Single command
> line mode.
>
>>
>>  *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.
>>>
>>
>> This is true for Single line commands. But since we use Basic Auth, AFAIK
>> we do not login every time for prompt mode.
>>
> Yes. In Interactive Mode, we need to login to enter the prompt. If we can
> save authentication details, we do not have to login at this time also.
>

IMO no need to worry about this initial log-in step. If someone needs
the session why would he logout from prompt.
Eg. *Mysql*.


>>
>>>
>>> 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
>>>
>> So are we planning to ship as Jar and script file as we had before?
>>
> Yes. We need to provide wrappers, eg. script files for different
> environments.
>
> Any suggestions?
>

Ideally, i was thinking of a tool like mysql. You do not have any artifacts
in an one directory, but install the tool to machine. Then you use it.

>
>> Thanks.
>>
>
> [1]
> 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/src/main/java/org/wso2/carbon/adc/mgt/cli/parsers/LineParser.java
>
>>
>>> 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
>>> [email protected]
>>> https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture
>>>
>>>
>>
>>
>> --
>> --
>> Lahiru Sandaruwan
>> Software Engineer,
>> Platform Technologies,
>> WSO2 Inc., http://wso2.com
>> lean.enterprise.middleware
>>
>> email: [email protected] cell: (+94) 773 325 954
>> blog: http://lahiruwrites.blogspot.com/
>> twitter: http://twitter.com/lahirus
>> linked-in: http://lk.linkedin.com/pub/lahiru-sandaruwan/16/153/146
>>
>>
>> _______________________________________________
>> Architecture mailing list
>> [email protected]
>> 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
> [email protected]
> https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture
>
>


-- 
--
Lahiru Sandaruwan
Software Engineer,
Platform Technologies,
WSO2 Inc., http://wso2.com
lean.enterprise.middleware

email: [email protected] cell: (+94) 773 325 954
blog: http://lahiruwrites.blogspot.com/
twitter: http://twitter.com/lahirus
linked-in: http://lk.linkedin.com/pub/lahiru-sandaruwan/16/153/146
_______________________________________________
Architecture mailing list
[email protected]
https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture

Reply via email to