Hi,
I coded that tree printing functionality, assuming it is a JSON structure
we have to print and it looks likes this one.
[
{
"name": "level-one-group",
"cartridges": [
"esb",
"tomcat"
],
"groups": [
{
"name": "level-two-group",
"cartridges": [
"esb",
"tomcat"
],
"groups": [
{
"name": "level-three-group",
"cartridges": [
"esb",
"tomcat"
]
}
]
}
]
}
]
Giving the following JSON, the output tree structure look likes the
following.
_
|
+-|
+-cartridges
+-|
| +-esb
| +-tomcat
+-name : level-one-group
+-groups
+-|
+-|
+-cartridges
+-|
| +-esb
| +-tomcat
+-name : level-two-group
+-groups
+-|
+-|
+-cartridges
+-|
| +-esb
| +-tomcat
+-name : level-three-group
Hope this is how you want it. We can change the styles if you like.
On Fri, Mar 27, 2015 at 7:11 PM, Milindu Sanoj Kumarage <
[email protected]> wrote:
> Hi,
>
> I have updated the proposal including more implementation details, and the
> demo app's details.
>
>
> Proposal : Python based Command Line Tool (CLI) for Stratos
> <https://docs.google.com/document/d/1ORkVPtFnJQi6szswKaim8ZCIKMHi3d3eCVOuA18GOG4/edit?usp=drive_web>
>
>
> Meanwhile, I'm implementing the tree printing functionality. What are the
> details that need to be printed? It is data relates to clusters that comes
> as a JSON, right? Can I have a sample JSON, please.
>
>
>
> On Thu, Mar 26, 2015 at 12:05 AM, Milindu Sanoj Kumarage <
> [email protected]> wrote:
>
>> Hi Imesh,
>>
>> Here I have uploaded a simple CLI demo to Pip, you can install it with
>> giving this command if you have Pip on your system.
>>
>> $ sudo pip install stratos
>>
>> then can invoke it simply calling it on CLI as,
>>
>> $ stratos
>>
>>
>> What I'm trying to demonstrate with this demo is the basic functionalists
>> of the CLI, like autocomplete option, help options, input/ output
>> redirection, etc. And ability to consume RESTful services via HTTP,
>> authenticating with HTTP Basic authentication. And also my ability to
>> create Python distributions.
>>
>> I'm using Github's API currently in order to demonstrate the ability to
>> make requests to API and get responses. Connecting to Github API with HTTP
>> Basic authentication.
>>
>>
>> *In the Interactive mode*
>>
>> 1. Give the 'user' command as follows. You will see your name and
>> email retrieved from the Github API.
>>
>> user -u <github-username> -p <github-password>
>>
>> 2. Type 're' and press Tab, it will complete the command.
>> 3. Type 'de' and press Tab, then the command will be completed up to
>> 'deploy-' then press Tab twice. It will show the possible commands.
>> 4. Type 'de' and press Tab, then the command will be completed up to
>> 'deploy-' then type 'u' and press Tab , it will complete the command.
>> 5. Type '?repositories' or 'help repositories' , this will show the
>> help options for 'repositories' command.
>> 6. Give the 'repositories' command as follows. You will see 5 of your
>> Github repositories in tabular format, retrieved from the Github API.
>>
>> repositories -u <github-username> -p <github-password>
>>
>> +----------------------+------------+
>> | Name | language |
>> +======================+============+
>> | backbone-boilerplate | JavaScript |
>> | CRUD.js | CSS |
>> | DeciesGraph | CSS |
>> | fancyBox | JavaScript |
>> | html5-boilerplate | JavaScript |
>> +----------------------+------------+
>>
>> 7. press up arrow key, you will the the last command issues, you can
>> traverse through the history using up and down arrow keys.
>> 8. Try history command, Try list command.
>> 9. Try giving a shell command, it will work in the same way the bash
>> works.
>>
>> !ls
>>
>> or
>>
>> shell ls
>>
>> *In the single command mode*
>>
>> 1. Issues the commands in the same way as in interactive mode.
>>
>> $ repositories -u <github-username> -p <github-password>
>>
>> 2. Issues this command in command line. It will write the output to a
>> file names 'out.txt'.
>>
>> stratos repositories -u <github-username> -p <github-password> >
>> out.txt
>>
>> 3. Issues this command in command line. It will pipe the output to
>> the grep command.
>>
>> stratos repositories -u <github-username> -p <github-password> |
>> grep JavaScript
>>
>> 4. Create a file with some commands, entered line by line, save it as
>> commands.txt, then give this command while in CMD. It will execute the
>> commands line by line and print the output to the console.
>>
>> stratos < commands.txt
>>
>> 5. Create a file with some commands, entered line by line, save it as
>> commands.txt, then give this command while in CMD. It will execute the
>> commands line by line and print the output to out.txt file.
>>
>> stratos < commands.txt > out.txt
>>
>>
>>
>> ( I developed and tested this on Linux with Python 2.7 version )
>>
>>
>
> On Thu, Mar 26, 2015 at 12:05 AM, Milindu Sanoj Kumarage <
> [email protected]> wrote:
>
>> Hi Imesh,
>>
>> Here I have uploaded a simple CLI demo to Pip, you can install it with
>> giving this command if you have Pip on your system.
>>
>> $ sudo pip install stratos
>>
>> then can invoke it simply calling it on CLI as,
>>
>> $ stratos
>>
>>
>> What I'm trying to demonstrate with this demo is the basic functionalists
>> of the CLI, like autocomplete option, help options, input/ output
>> redirection, etc. And ability to consume RESTful services via HTTP,
>> authenticating with HTTP Basic authentication. And also my ability to
>> create Python distributions.
>>
>> I'm using Github's API currently in order to demonstrate the ability to
>> make requests to API and get responses. Connecting to Github API with HTTP
>> Basic authentication.
>>
>>
>> *In the Interactive mode*
>>
>> 1. Give the 'user' command as follows. You will see your name and
>> email retrieved from the Github API.
>>
>> user -u <github-username> -p <github-password>
>>
>> 2. Type 're' and press Tab, it will complete the command.
>> 3. Type 'de' and press Tab, then the command will be completed up to
>> 'deploy-' then press Tab twice. It will show the possible commands.
>> 4. Type 'de' and press Tab, then the command will be completed up to
>> 'deploy-' then type 'u' and press Tab , it will complete the command.
>> 5. Type '?repositories' or 'help repositories' , this will show the
>> help options for 'repositories' command.
>> 6. Give the 'repositories' command as follows. You will see 5 of your
>> Github repositories in tabular format, retrieved from the Github API.
>>
>> repositories -u <github-username> -p <github-password>
>>
>> +----------------------+------------+
>> | Name | language |
>> +======================+============+
>> | backbone-boilerplate | JavaScript |
>> | CRUD.js | CSS |
>> | DeciesGraph | CSS |
>> | fancyBox | JavaScript |
>> | html5-boilerplate | JavaScript |
>> +----------------------+------------+
>>
>> 7. press up arrow key, you will the the last command issues, you can
>> traverse through the history using up and down arrow keys.
>> 8. Try history command, Try list command.
>> 9. Try giving a shell command, it will work in the same way the bash
>> works.
>>
>> !ls
>>
>> or
>>
>> shell ls
>>
>> *In the single command mode*
>>
>> 1. Issues the commands in the same way as in interactive mode.
>>
>> $ repositories -u <github-username> -p <github-password>
>>
>> 2. Issues this command in command line. It will write the output to a
>> file names 'out.txt'.
>>
>> stratos repositories -u <github-username> -p <github-password> >
>> out.txt
>>
>> 3. Issues this command in command line. It will pipe the output to
>> the grep command.
>>
>> stratos repositories -u <github-username> -p <github-password> |
>> grep JavaScript
>>
>> 4. Create a file with some commands, entered line by line, save it as
>> commands.txt, then give this command while in CMD. It will execute the
>> commands line by line and print the output to the console.
>>
>> stratos < commands.txt
>>
>> 5. Create a file with some commands, entered line by line, save it as
>> commands.txt, then give this command while in CMD. It will execute the
>> commands line by line and print the output to out.txt file.
>>
>> stratos < commands.txt > out.txt
>>
>>
>>
>> ( I developed and tested this on Linux with Python 2.7 version )
>>
>>
>