Skip to content

JREAM/cli-aid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CLI Snippet Tool

This is a Python 2.6/2.7 package to be used in your command line to easily assist you with your favorite snippets.

[Soon to be Python3 compatible as well.]

STATUS: In Development

Save Development Time

Although there are Linux man(ual) pages and many --help flags, even the most seasoned developers forget many commands and at times simply cannot recall.

Most of us turn to Google, yet it's sometimes tedious to find our solution more than once.

The greatest benefit is that you can build your own snippet library easily within your terminal and access it from your terminal on any Linux OS!

Fork: Feel free to fork and customize to your liking. I highly recommend you keep it in your own git repository to transfer it from different computers and servers.

Definitions

  • TOPICS: Where methods define help instructions
    • SERVICE: The first command you want information about (eg: git, find, etc)
    • COMMAND: The second command to look up with a service, for example:
      • ./cli-aid.py <service> <command>
      • ./cli-aid.py git submodule
  • MODULE: There is only one module: topics, which stores all of your items.

Custom Topics

Adding a topic is very easy. You should look at topics/demo.py for an example. To se the output in action, try these three commands:

./cli-aid.py demo basic        ; A text output
./cli-aid.py demo standard     ; A dictionary output
./cli-aid.py demo wrong        ; An error output

Rules to Topics

  • The topic/filename will be the first argument
  • The topic/filename methods can be used as a second argument
  • Topics must always return something, valid options:
    • String
    • Dictionary in the format of: {'flags': '..', 'commands': '...'}

Writing your Topic

If I wanted to create an example topic I would first figure out the commands I want to remember. So for mysql I may want to be able to type:

./cli-aid.py mysql connect
./cli-aid.py mysql tricks

To accomplish this is very easy:

touch topics/mysql.py

Edit the new file let's define our second arguments, I'll provide the basic (string) and standard (dictionary) output examples.

Remember: You can put any output in these you want, it's for you to help yourself.

def connect():
    """This is a standard dictionary return."""
    return {
        'flags': """
            -u  --user
            -p  --password[=name]
            -P  --port=#
            -v  --verbose
        """,
        'commands': """
            mysql -u root -p
            mysql -u root -p -h localhost
        """
    }

def tricks():
    """This is a basic string return."""
    return """
    user@localhost limits to the same server
    user@% allows remote connections
    """

That's it, now you should be able to run it, try it out!

./cli-aid.py mysql connect
./cli-aid.py mysql tricks

Road Map & Contributing

If you have the desire to contribute the goal to keep in mind is this:

  • The code should be extremely simple.
  • There should be no third-party addons for the users benefit.
  • Would like to do/Plans:
    • Unit Testing
    • Should user have ability to easily create new topics/details? For example:
      • ./cli-aid.py save java install "This is how to install java, etc." (save would create/update)
      • ./cli-aid.py save nginx config "flags: -y auto yes"
      • ./cli-aid.py save nginx config "commands: Anything here like a textfield"
      • The above seems hard to format in one line unless it's basic text. However, using the save method could keep adding to the same file, but removing items would be problematic with string searching to the exact wording they wrote in the past.
      • I think if the user is using CLI they are good enough to simply vim topics/their-file.py.
    • More/Better Error Proofing
    • Possibly a better syntax or format for the topic files
    • Python 3 compatible
    • One argument produces a list of method names within the topic (module).
    • A nice shortname rather than cli-aid
      • Some name ideas:
        • snippette (too long)
        • snipr (too much typing, sounds like sniper)
        • scrap (sounds like garbage, or close to scraper)
        • hlp (I kind of like, easy to type and remember, something to do with 'help' seems best)
        • assist (seems nice, like when typing assist mysql connect )
        • aid (I really like this, aid php config, may be under the id-utils package though has this alias which runs lid -ils )
          • maybe even cli-aid, cli-aid find list
        • ayd (sounds like aid, not as easy to type)
        • hh (short to type, might fight with an alias, also doesn't explain much)
    • Complete the Install Script, so it can be run from a nice name, eg: $ hlp js snippets with out disrupting any other system commands or common words.
  • Any ideas are also welcomed, just create a Git Issue!

License: MIT

©2017 Jesse Boyer — JREAM