Skip to content
/ gists Public
forked from nacx/gists

Python CLI interface for managing gists

License

Notifications You must be signed in to change notification settings

jesuspg/gists

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gists

CLI interface for managing GitHub gists

Install it

Two ways of installation:

  • Download the source code, extract it, and execute python setup.py install
  • pip install gists

Configure it

First time you run 'gists', execute the command

$ gists authorize -u your_github_user -s your_github_password

And the file ~/.gistsrc (which stores the 'gists' configuration) will be written with your GitHub api authentication token.

Anytime you can revoke your authentication token in your applications page on GitHub.

Use it!

Set up credentials

Gists uses the file '~/.gistsrc' to obtain your GitHub authentication token. First thing you need to do is set up your credentials to perform actions that needs authentication. Method is just:

$ gists authorize -u your_github_user -s your_github_password

You can perform this actions many times you wish to override the values.

If you don't want to authorize the app, you can always use the -u and -s parameters to provide the credentials in each command.

List of Gists

Basic Usage

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.

More arguments:

  • -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)

Show a Gist

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 Gist

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.

More arguments

  • -o (--output_dir) destination directory where you want to save the gist

Create a 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.

More arguments

  • -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 a Gist

Update an existent Gist. Several examples:

Modify just the description

To modify the description, use the -d (--description) argument:

$ gists update e110cc498a31dc442fc3 -d "New gist description"

Modify the contents of a file

Modify the contents of a File that already exists in the Gist:

$ gists update e110cc498a31dc442fc3 -f examplegist.txt

Add a new file to a Gist

Modify a Gist adding a new file, using the -n (--new) argument:

$ gists update e110cc498a31dc442fc3 -f new_file_to_gist.py -n

Remove a file from a Gist

Modify a Gist removing one of its files, using the -r (--remove) argument:

$ gists update e110cc498a31dc442fc3 -f no_longer_needed_file.py -r

More arguments

  • -i (--input_dir) Specify the input directory where the file is.

About

Python CLI interface for managing gists

Resources

License

Stars

Watchers

Forks

Packages

No packages published