Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Set description from CLI (for issue #73) #74

Closed
wants to merge 3 commits into from

3 participants

@flores

Just uses a -d/--description flag.

$ ./gist -h
Usage: gist [options] [filename or stdin] [filename] ...
Filename '-' forces gist to read from stdin.
-p, --[no-]private Make the gist private
-d, --description [DESCRIPTION] Set the description of gist
-t, --type [EXTENSION] Set syntax highlighting of the Gist by file extension
-o, --[no-]open Open gist in browser
-m, --man Print manual
-v, --version Print version
-h, --help Display this screen
-c, --[no-]copy Copy gist URL to clipboard automatically

@steakknife

Awesome, just what I was looking for.

Manually tested the CLI with and without -d, gists created as expected. :cake: and :beer: for you.

Bonus :stars: for test cases.

Also, passing files via command-line seemed to break, might be unrelated: 'Creating gist failed: 200 OK'.

@ConradIrwin ConradIrwin closed this pull request from a commit
@ConradIrwin ConradIrwin Merge jist with gist!
After some time as a fork, and a lot of vetting from users, we have
decided to merge the projects together.

The key change is to use OAuth tokens for authentication instead of
requiring you to hard-code your password. Please use `gist --login`
to exchange your username and password for a token.

Close #137  Gist API now requires user-agent be set, and some versions of Net::HTTP don't 3 ↑
Close #136  SSL error (w/ Homebrew & Ruby 2.0.0-p0 from rbenv)
Close #135  Moved authentication over to OAuth tokens. 1 ↑
Close #134  Trying to use gist inside a directory with dashes in the name on a file inside a subdirectory of that results in 422 errors.... 3
Close #133  SSL cert cached in /tmp
Close #132  --open doesn't works
Close #131  Replace slashes with dashes to avoid 422 errors ↑
Close #130  FEATURE: Multiple API Providers 2 ↑
Close #125  Preventing gist from throwing errors when xclip is installed but X11 isn't present (forwarding or otherwise) ↑
Close #120  Add link shortening with --shorten / -s option ↑
Close #118  Use tokens instead of username / password 4
Close #117  Integrate with git.io
Close #116  man page typos & feature request
Close #115  Creating gist failed: 500 Internal Server Error 1
Close #112  Refactor reading from stdin so --type option works 3 ↑
Close #111  Allow gist to work against different githubs 2 ↑
Close #109  fix error on windows. ↑
Close #108  set Content-Type. 5 ↑
Close #107  Add update support. 1 ↑
Close #106  Add anonymous gisting. 1 ↑
Close #103  fix some bugs.  make gist rock in vim/editor via "highlight lines - :!gist" ↑
Close #98  SSL... 23
Close #96  Creating gist failed: 422 Unprocessable Entity 2
Close #95  Fixes the extension issue for -t syntax highlighting, and the filename for stdin 5 ↑
Close #94  show JSON response when create fails ↑
Close #93  use file basename by default 4 ↑
Close #91  Support using an oauth token rather than a username+password 7 ↑
Close #90  3.1.0 fails to authenticate 3
Close #88  Current (3.1.0) no longer respects -t flag 3
Close #85  Copy to clipboard in Windows ↑
Close #84  use oauth now that there are no tokens 14
Close #78  Strip directory from arguments 2
Close #76  Some README.markdown nitpicks...
Close #75  Does not open in browser by default — documentation disagrees 3
Close #74  Set description from CLI (for issue #73) 1 ↑
Close #73  Should be able to set gist description from commandline 1
Close #69  Failed gist creation should raise instead of puts and exit.
Close #67  Use the github api and allow gist url override. 1 ↑
Close #65  Handle lowercased versions of HTTP_PROXY and HTTPS_PROXY. 1 ↑
Close #64  When generating the man page (-m/--man), skip the usage instructions ↑
Close #61  Instructions for setting github.token to a command don't work for me 1
Close #58  support for anonymous gists
Close #53  Add support for GitHub:FI 4
Close #25  Support for updating gists [feature] 1
a05092f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 6, 2012
  1. @flores
Commits on Mar 4, 2012
  1. @ainformatico
Commits on Mar 5, 2012
  1. @flores

    Merge pull request #1 from ainformatico/master

    flores authored
    Added man documentation for gist documentation option
This page is out of date. Refresh to see the latest.
Showing with 18 additions and 4 deletions.
  1. +10 −4 gist
  2. +4 −0 man/gist.1
  3. +1 −0  man/gist.1.html
  4. +3 −0  man/gist.1.ron
View
14 gist
@@ -108,6 +108,7 @@ module Gist
def execute(*args)
private_gist = defaults["private"]
gist_filename = nil
+ gist_description = nil
gist_extension = defaults["extension"]
browse_enabled = defaults["browse"]
copy = defaults["copy"]
@@ -120,6 +121,10 @@ module Gist
private_gist = priv
end
+ opts.on('-d','--description [DESCRIPTION]', "Set the description of gist") do |desc|
+ gist_description = desc
+ end
+
t_desc = 'Set syntax highlighting of the Gist by file extension'
opts.on('-t', '--type [EXTENSION]', t_desc) do |extension|
gist_extension = '.' + extension
@@ -173,7 +178,7 @@ module Gist
files = [{:input => input, :extension => gist_extension}]
end
- url = write(files, private_gist)
+ url = write(files, private_gist, gist_description)
browse(url) if browse_enabled
copy(url) if copy
$stdout.tty? ? puts(url) : print(url)
@@ -183,7 +188,7 @@ module Gist
end
end
- def write(files, private_gist = false)
+ def write(files, private_gist = false, gist_description = nil)
url = URI.parse(CREATE_URL)
if PROXY_HOST
@@ -198,7 +203,7 @@ module Gist
http.ca_file = ca_cert
req = Net::HTTP::Post.new(url.path)
- req.form_data = data(files, private_gist)
+ req.form_data = data(files, private_gist, gist_description)
response = http.start{|h| h.request(req) }
case response
@@ -241,7 +246,7 @@ module Gist
end
private
- def data(files, private_gist)
+ def data(files, private_gist, gist_description)
data = {}
files.each do |file|
i = data.size + 1
@@ -249,6 +254,7 @@ private
data["file_name[gistfile#{i}]"] = file[:filename]
data["file_contents[gistfile#{i}]"] = file[:input]
end
+ data["description"] = gist_description if gist_description
data.merge(private_gist ? { 'action_button' => 'private' } : {}).merge(auth)
end
View
4 man/gist.1
@@ -25,6 +25,10 @@ Once your gist is successfully created, the URL will be copied to your clipboard
These options can be used to change this behavior:
.
.TP
+\fB\-d\fR, \fB\-\-description\fR
+Set the description of gist\.
+.
+.TP
\fB\-p\fR, \fB\-\-private\fR
Create a private gist instead of a public gist\.
.
View
1  man/gist.1.html
@@ -105,6 +105,7 @@ <h2 id="OPTIONS">OPTIONS</h2>
<p>These options can be used to change this behavior:</p>
<dl>
+<dt><code>-d</code>, <code>--description</code></dt><dd><p>Set the description of gist.</p></dd>
<dt><code>-p</code>, <code>--private</code></dt><dd><p>Create a private gist instead of a public gist.</p></dd>
<dt><code>-t</code>, <code>--type</code></dt><dd><p>Set the file extension explicitly. Passing a type of <code>rb</code> ensures
the gist is created as a Ruby file.</p></dd>
View
3  man/gist.1.ron
@@ -28,6 +28,9 @@ to your GitHub account if you user and token are provided (see
These options can be used to change this behavior:
+ * `-d`, `--description`:
+ Set the description of gist.
+
* `-p`, `--private`:
Create a private gist instead of a public gist.
Something went wrong with that request. Please try again.