Skip to content

Commit

Permalink
Rewrite man page so it looks ok in ronn
Browse files Browse the repository at this point in the history
  • Loading branch information
ConradIrwin committed May 3, 2013
1 parent 447f735 commit 5a36b3d
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 110 deletions.
177 changes: 68 additions & 109 deletions README.md
@@ -1,120 +1,92 @@
Gist is a gem that allows you to publish a [gist](https://gist.github.com) from Ruby.
gist(1) -- upload code to https://gist.github.com
=================================================

# Installation
## Synopsis

As with all ruby gems, you can install Gist (assuming you have ruby and rubygems) with:
The gist gem provides a `gist` command that you can use from your terminal to
upload content to https://gist.github.com/.

```shell
$ gem install gist
```
## Installation

If you want to use the library in your application, and you're using Bundler. Add the
following to your Gemfile.
‌If you have ruby installed:

```ruby
source :rubygems
gem 'gist'
```
gem install gist

# Command
‌If you're using Bundler:

The gist gem provides a `gist` command that you can use from your terminal to
upload content to https://gist.github.com/.
source :rubygems
gem 'gist'

## Command

‌To upload the contents of `a.rb` just:

gist a.rb

‌Upload multiple files:

gist a b c
gist *.rb

‌By default it reads from STDIN, and you can set a filename with `-f`.

It's easy to use. To upload the contents of `a.rb` just:
gist -f test.rb <a.rb

```shell
$ gist a.rb
https://gist.github.com/0d07bc98c139810a4075
```
‌Alternatively, you can just paste from the clipboard:

Upload multiple files :
```shell
$ gist a b c
$ gist *.rb
```
gist -P

By default it reads from STDIN, and you can set a filename with `-f`.
‌Use `-p` to make the gist private:

```shell
$ gist -f test.rb <a.rb
https://gist.github.com/7db51bb5f4f35c480fc8
```
gist -p a.rb

Alternatively, you can just paste from the clipboard:
‌Use `-d` to add a description:

```shell
$ gist -P
https://gist.github.com/6a330a11a0db8e52a6ee
```
gist -d "Random rbx bug" a.rb

Use `-p` to make the gist public and `-d` to add a description.
```shell
$ gist -p -d "Random rbx bug" a.rb
https://gist.github.com/2977722
```
‌You can update existing gists with `-u`:

You can update existing gists with `-u`:
gist lib/gist.rb bin/gist -u 42f2c239d2eb57299408

```shell
$ gist lib/gist.rb bin/gist -u 42f2c239d2eb57299408
https://gist.github.com/42f2c239d2eb57299408
```
‌If you'd like to copy the resulting URL to your clipboard, use `-c`.

If you'd like to copy the resulting URL to your clipboard, use `-c`.
gist -c <a.rb

```shell
$ gist -c <a.rb
https://gist.github.com/7db51bb5f4f35c480fc8
```
‌If you'd like to copy the resulting embeddable URL to your clipboard, use `--copy-js`.

If you'd like to copy the resulting embeddable URL to your clipboard, use `--copy-js`.
gist --copy-js <a.rb

```shell
$ gist --copy-js <a.rb
<script src="https://gist.github.com/7db51bb5f4f35c480fc8"></script>
```
And you can just ask gist to open a browser window directly with `-o`.
‌And you can just ask gist to open a browser window directly with `-o`.

```shell
$ gist -o <a.rb
https://gist.github.com/7db51bb5f4f35c480fc8
```
gist -o <a.rb

See `gist --help` for more detail.
See `gist --help` for more detail.

## Login

If you want to associate your gists with your github account, you need to login
If you want to associate your gists with your GitHub account, you need to login
with gist. It doesn't store your username and password, it just uses them to get
an OAuth2 token (with the "gist" permission).

```shell
gist --login
Obtaining OAuth2 access_token from github.
Github username: ConradIrwin
Github password:
Success! https://github.com/settings/applications
```
gist --login
Obtaining OAuth2 access_token from github.
GitHub username: ConradIrwin
GitHub password:
Success! https://github.com/settings/applications

This token is stored in `~/.gist` and used for all future gisting. If you need to
you can revoke it from https://github.com/settings/applications, or just delete the
file.

After you've done this, you can still upload gists anonymously with `-a`.
After you've done this, you can still upload gists anonymously with `-a`.

```shell
gist -a a.rb
https://gist.github.com/6bf7ec379fc9119b1f15
```
gist -a a.rb

# Library

You can also use Gist as a library from inside your ruby code:
You can also use Gist as a library from inside your ruby code:

```ruby
Gist.gist("Look.at(:my => 'awesome').code")
```
Gist.gist("Look.at(:my => 'awesome').code")

If you need more advanced features you can also pass:

Expand All @@ -129,61 +101,48 @@ If you need more advanced features you can also pass:

NOTE: The access_token must have the "gist" scope.

If you want to upload multiple files in the same gist, you can:
If you want to upload multiple files in the same gist, you can:

```ruby
Gist.multi_gist("a.rb" => "Foo.bar", "a.py" => "Foo.bar")
```
Gist.multi_gist("a.rb" => "Foo.bar", "a.py" => "Foo.bar")

If you'd rather use gist's builtin access_token, then you can force the user to
obtain one by calling:
If you'd rather use gist's builtin access_token, then you can force the user
to obtain one by calling:

```ruby
Gist.login!
```
Gist.login!

This will take them through the process of obtaining an OAuth2 token, and storing it
This will take them through the process of obtaining an OAuth2 token, and storing it
in `~/.gist`, where it can later be read by `Gist.gist`

GitHub enterprise
==================
## GitHub enterprise

If you'd like `gist` to use your locally installed [Github Enterprise](https://enterprise.github.com/),
If you'd like `gist` to use your locally installed [GitHub Enterprise](https://enterprise.github.com/),
you need to export the `GITHUB_URL` environment variable in your `~/.bashrc`.

```bash
export GITHUB_URL=http://github.internal.example.com/
```
export GITHUB_URL=http://github.internal.example.com/

Once you've done this and restarted your terminal (or run `source ~/.bashrc`), gist will
Once you've done this and restarted your terminal (or run `source ~/.bashrc`), gist will
automatically use github enterprise instead of the public github.com

Configuration
=============
## Configuration

If you'd like `-o` or `-c` to be the default when you use the gist executable, add an
If you'd like `-o` or `-c` to be the default when you use the gist executable, add an
alias to your `~/.bashrc` (or equivalent). For example:

```ruby
alias gist='gist -c'
```
alias gist='gist -c'

If you'd prefer gist to open a different browser, then you can export the BROWSER
If you'd prefer gist to open a different browser, then you can export the BROWSER
environment variable:

```ruby
export BROWSER=google-chrome
```
export BROWSER=google-chrome

If clipboard or browser integration don't work on your platform, please file a bug or
(more ideally) a pull request.

If you need to use an HTTP proxy to access the internet, export the `HTTP_PROXY` or
`http_proxy` environment variable and gist will use it.

Meta-fu
=======
## Meta-fu

I wrote this because the `gist` gem is out of action, and has been for many months.
Thanks to @defunkt and @indirect for writing and maintaining versions 1 through 3.

It's licensed under the MIT license, and bug-reports, and pull requests are welcome.
Licensed under the MIT license. Bug-reports, and pull requests are welcome.
9 changes: 9 additions & 0 deletions Rakefile
@@ -1,3 +1,5 @@
# encoding: utf-8
#
task :default => :test

desc 'run the tests' # that's non-DRY
Expand All @@ -8,3 +10,10 @@ end
task :clipfailtest do
sh 'PATH=/ /usr/bin/ruby -Ilib -S bin/gist -ac < lib/gist.rb'
end

task :man do
File.write "README.md.ron", File.read("README.md").gsub(?‌, "* ")
sh 'ronn --roff --manual="Gist manual" README.md.ron'
rm 'README.md.ron'
sh 'man ./README.1'
end
2 changes: 1 addition & 1 deletion gist.gemspec
Expand Up @@ -14,7 +14,7 @@ Gem::Specification.new do |s|
s.executables << 'gist'

s.add_dependency 'json'
%w(rake rspec webmock).each do |gem|
%w(rake rspec webmock ronn).each do |gem|
s.add_development_dependency gem
end
end

0 comments on commit 5a36b3d

Please sign in to comment.