Merge pull request #457 from urfave/readme-toc

Generate TOC in README
This commit is contained in:
Dan Buch 2016-06-16 15:48:14 -04:00 committed by GitHub
commit b438abf775
4 changed files with 50 additions and 4 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
*.coverprofile *.coverprofile
node_modules/

View File

@ -2,6 +2,10 @@ language: go
sudo: false sudo: false
cache:
directories:
- node_modules
go: go:
- 1.2.2 - 1.2.2
- 1.3.3 - 1.3.3
@ -25,8 +29,12 @@ matrix:
before_script: before_script:
- go get github.com/urfave/gfmxr/... - go get github.com/urfave/gfmxr/...
- if [ ! -f node_modules/.bin/markdown-toc ] ; then
npm install markdown-toc ;
fi
script: script:
- ./runtests vet - ./runtests vet
- ./runtests test - ./runtests test
- ./runtests gfmxr - ./runtests gfmxr
- ./runtests toc

View File

@ -1,3 +1,6 @@
cli
===
[![Build Status](https://travis-ci.org/urfave/cli.svg?branch=master)](https://travis-ci.org/urfave/cli) [![Build Status](https://travis-ci.org/urfave/cli.svg?branch=master)](https://travis-ci.org/urfave/cli)
[![Windows Build Status](https://ci.appveyor.com/api/projects/status/rtgk5xufi932pb2v?svg=true)](https://ci.appveyor.com/project/urfave/cli) [![Windows Build Status](https://ci.appveyor.com/api/projects/status/rtgk5xufi932pb2v?svg=true)](https://ci.appveyor.com/project/urfave/cli)
[![GoDoc](https://godoc.org/github.com/urfave/cli?status.svg)](https://godoc.org/github.com/urfave/cli) [![GoDoc](https://godoc.org/github.com/urfave/cli?status.svg)](https://godoc.org/github.com/urfave/cli)
@ -6,9 +9,6 @@
[![top level coverage](https://gocover.io/_badge/github.com/urfave/cli?0 "top level coverage")](http://gocover.io/github.com/urfave/cli) / [![top level coverage](https://gocover.io/_badge/github.com/urfave/cli?0 "top level coverage")](http://gocover.io/github.com/urfave/cli) /
[![altsrc coverage](https://gocover.io/_badge/github.com/urfave/cli/altsrc?0 "altsrc coverage")](http://gocover.io/github.com/urfave/cli/altsrc) [![altsrc coverage](https://gocover.io/_badge/github.com/urfave/cli/altsrc?0 "altsrc coverage")](http://gocover.io/github.com/urfave/cli/altsrc)
# cli
**Notice:** This is the library formerly known as **Notice:** This is the library formerly known as
`github.com/codegangsta/cli` -- Github will automatically redirect requests `github.com/codegangsta/cli` -- Github will automatically redirect requests
to this repository, but we recommend updating your references for clarity. to this repository, but we recommend updating your references for clarity.
@ -17,6 +17,37 @@ cli is a simple, fast, and fun package for building command line apps in Go. The
goal is to enable developers to write fast and distributable command line goal is to enable developers to write fast and distributable command line
applications in an expressive way. applications in an expressive way.
<!-- toc -->
- [Overview](#overview)
- [Installation](#installation)
* [Supported platforms](#supported-platforms)
* [Using the `v2` branch](#using-the-v2-branch)
* [Pinning to the `v1` branch](#pinning-to-the-v1-branch)
- [Getting Started](#getting-started)
- [Examples](#examples)
* [Arguments](#arguments)
* [Flags](#flags)
+ [Placeholder Values](#placeholder-values)
+ [Alternate Names](#alternate-names)
+ [Values from the Environment](#values-from-the-environment)
+ [Values from alternate input sources (YAML and others)](#values-from-alternate-input-sources-yaml-and-others)
* [Subcommands](#subcommands)
* [Subcommands categories](#subcommands-categories)
* [Exit code](#exit-code)
* [Bash Completion](#bash-completion)
+ [Enabling](#enabling)
+ [Distribution](#distribution)
+ [Customization](#customization)
* [Generated Help Text](#generated-help-text)
+ [Customization](#customization-1)
* [Version Flag](#version-flag)
+ [Customization](#customization-2)
+ [Full API Example](#full-api-example)
- [Contribution Guidelines](#contribution-guidelines)
<!-- tocstop -->
## Overview ## Overview
Command line apps are usually so tiny that there is absolutely no reason why Command line apps are usually so tiny that there is absolutely no reason why

View File

@ -18,7 +18,8 @@ def main(sysargs=sys.argv[:]):
targets = { targets = {
'vet': _vet, 'vet': _vet,
'test': _test, 'test': _test,
'gfmxr': _gfmxr 'gfmxr': _gfmxr,
'toc': _toc,
} }
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
@ -62,6 +63,11 @@ def _vet():
_run('go vet ./...'.split()) _run('go vet ./...'.split())
def _toc():
_run(['node_modules/.bin/markdown-toc', '-i', 'README.md'])
_run(['git', 'diff', '--quiet'])
def _run(command): def _run(command):
print('runtests: {}'.format(' '.join(command)), file=sys.stderr) print('runtests: {}'.format(' '.join(command)), file=sys.stderr)
check_call(command) check_call(command)