CLI interface for managing GitHub gists
Two ways of installation:
- Download the source code, extract it, and execute
python setup.py install
pip install gists
First time you run 'gists', execute the command
$ gists credentials -u your_github_user -s your_github_password
And the file ~/.gistsrc (which stores the 'gists' configuration) will be written with your GitHub username and its password.
You can live without this config file using the '-u (--user)' argument every time you perform an action, and '-s (--secret)' argument every time you perform an action that needs authentication (create, update, delete gists, and view private gists as well).
Gists uses the file '~/.gistsrc' to obtain your GitHub user and password. First thing you need to do is set up your credentials to perform actions that needs authentication. Method is just:
$ gists credentials -u your_github_user -s your_github_password
You can perform this actions many times you wish to override the values.
Return a list of gists. Basic usage is:
$ gists list
This will return a list of Gists from field user from [credentials] section in your (~/.gistsrc) file.
- -u (--user) specifies from whom user you want to retrieve his/her gists.
- -p (--private) retrieves the private gists from the user besides the public ones. (Needs authentication)
- -s (--secret) overrides the password from the (~/.gistsrc) file.
Shows the detail of a Gist. There are two modes here: without the -f argument, that will show the Gist metadata (url, description, name of the files...) and with the -f argument, that shows the content of one of the files of the Gist. Identifier of the Gist, (obtained via gists list
) is mandatory as first argument.
Example without -f argument:
$ gists show e110cc498a31dc442fc3
Example with -f argument:
$ gists show e110cc498a31dc442fc3 -f examplegist.txt
Download a file from a Gist using the 'get' action. While in the 'show' action the parameter -f is optional depending on the kind of data you want to show, here is mandatory. So, a basic usage is:
$ gists get e110cc498a31dc442fc3 -f examplegist.txt
The name of the target file in your OS will be the same of the argument provided by -f. There is no way to change this.
- -o (--output_dir) destination directory where you want to save the gist
Creates a Gist. Needs a file to be uploaded. So, authentication and -f arguments are required. Basic usage is:
$ gists create -f examplegist.txt
The name of the file in the OS will be the same of the name of the file in the Gist. No way to change this.
- -u (--user) Overrides the default user specified in ~/.gistsrc file. This will be the owner of the Gist. If you specify this argument you might need to use the -s as well.
- -s (--secret) Overrides the default password specified in ~/.gistsrc file.
- -p (--private) whenever you want the Gist to be private.
- -d (--description) Set the description of the Gist.
- -i (--input_dir) Specify the input directory where the file is.
Update an existent Gist. Several examples:
To modify the description, use the -d (--description) argument:
$ gists update e110cc498a31dc442fc3 -d "New gist description"
Modify the contents of a File that already exists in the Gist:
$ gists update e110cc498a31dc442fc3 -f examplegist.txt
Modify a Gist adding a new file, using the -n (--new) argument:
$ gists update e110cc498a31dc442fc3 -f new_file_to_gist.py -n
Modify a Gist removing one of its files, using the -r (--remove) argument:
$ gists update e110cc498a31dc442fc3 -f no_longer_needed_file.py -r
- -u (--user) Overrides the default user specified in ~/.gistsrc file. This will be the owner of the Gist. If you specify this argument you might need to use the -s as well.
- -s (--secret) Overrides the default password specified in ~/.gistsrc file.
- -i (--input_dir) Specify the input directory where the file is.