Skip to content
This repository has been archived by the owner on Dec 20, 2024. It is now read-only.

Commit

Permalink
feature: add gen-doc command to auto gen dfget cli docs
Browse files Browse the repository at this point in the history
Signed-off-by: Allen Sun <[email protected]>
  • Loading branch information
allencloud committed Jan 16, 2019
1 parent 05f077d commit f551ff0
Show file tree
Hide file tree
Showing 27 changed files with 7,369 additions and 86 deletions.
39 changes: 39 additions & 0 deletions cmd/dfget/app/gen_doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package app

import (
"fmt"
"os"

"github.com/spf13/cobra"
"github.com/spf13/cobra/doc"
)

// GenDocCommand is used to implement 'gen-doc' command.
type GenDocCommand struct {
cmd *cobra.Command
}

func init() {
genDocCommand := &GenDocCommand{}
genDocCommand.cmd = &cobra.Command{
Use: "gen-doc",
Short: "Generate Document for dfget command line tool with MarkDown format",
SilenceErrors: true,
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
return genDocCommand.runGenDoc(args)
},
}
rootCmd.AddCommand(genDocCommand.cmd)
}

func (g *GenDocCommand) runGenDoc(args []string) error {
// FIXME: make document path configurable
if _, err := os.Stat("../../docs/cli_reference"); err != nil {
if os.IsNotExist(err) {
return fmt.Errorf("directory ../../docs/cli_reference does not exist")
}
return err
}
return doc.GenMarkdownTree(g.cmd.Parent(), "../../docs/cli_reference")
}
7 changes: 4 additions & 3 deletions cmd/dfget/app/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ var (
var cfg = config.NewConfig()

var rootCmd = &cobra.Command{
Use: "dfget",
Short: "The dfget is the client of Dragonfly.",
Long: "The dfget is the client of Dragonfly, a non-interactive P2P downloader.",
Use: "dfget",
Short: "The dfget is the client of Dragonfly.",
Long: "The dfget is the client of Dragonfly, a non-interactive P2P downloader.",
DisableAutoGenTag: true, // disable displaying auto generation tag in cli docs
RunE: func(cmd *cobra.Command, args []string) error {
return runDfget(args)
},
Expand Down
113 changes: 30 additions & 83 deletions docs/cli_reference/dfget.md
Original file line number Diff line number Diff line change
@@ -1,96 +1,43 @@
---
title: "dfget"
weight: 5
---
## dfget

dfget is the client of Dragonfly. You can use the dfget command in the command line tool.
<!--more-->
The dfget is the client of Dragonfly.

## Name
### Synopsis

dfget - the client of Dragonfly, a non-interactive P2P downloader.

## Synopsis

`dfget -u [URL] [options]...`

## Options
The dfget is the client of Dragonfly, a non-interactive P2P downloader.

```
-h, --help show this help message and exit
--url URL, -u URL will download a file from this url
--output OUTPUT, -O OUTPUT, -o OUTPUT
output path that not only contains the dir part but
also name part
--md5 MD5, -m MD5 expected file md5
--callsystem CALLSYSTEM
system name that executes dfget,its format is
company_department_appName
--notbs not back source when p2p fail
--locallimit LOCALLIMIT, -s LOCALLIMIT
rate limit about a single download task,its format is
20M/m/K/k
--totallimit TOTALLIMIT
rate limit about the whole host,its format is
20M/m/K/k
--identifier IDENTIFIER, -i IDENTIFIER
identify download task,it is available merely when md5
param not exist
--timeout TIMEOUT, --exceed TIMEOUT, -e TIMEOUT
download timeout(second)
--filter FILTER, -f FILTER
filter some query params of url ,e.g. -f 'key&sign'
will filter key and sign query param.in this
way,different urls correspond one same download task
that can use p2p mode
--showbar, -b show progress bar
--pattern {p2p,cdn}, -p {p2p,cdn}
download pattern,cdn pattern not support totallimit
--version, -v version
--node NODE, -n NODE specify nodes
--console show log on console
--header HEADER http header, e.g. --header="Accept: *" --header="Host:
abc"
--dfdaemon caller is from df-daemon
dfget [flags]
```

## Files

### /etc/dragonfly.conf

This is the default configuration file for dfget.
### Options

Before 0.2.0, only support INI config and only have one property(node) which specifies the address of the supernode:

```ini
[node]
address=127.0.0.1,10.10.10.1
```

Since 0.2.0, the INI config is just to be compatible with previous versions. We support INI(or conf) and YAML(since 0.2.0) both. The YAML config will have more properties:

```yaml
nodes:
- 127.0.0.1
- 10.10.10.1
localLimit: 20971520
totalLimit: 20971520
clientQueueSize: 6
--callsystem string system name that executes dfget
--console show log on console, it's conflict with '--showbar'
--dfdaemon caller is from dfdaemon
-f, --filter string filter some query params of url, use char '&' to separate different params
eg: -f 'key&sign' will filter 'key' and 'sign' query param
in this way, different urls correspond one same download task that can use p2p mode
--header strings http header, eg: --header='Accept: *' --header='Host: abc'
-h, --help help for dfget
-i, --identifier string identify download task, it is available merely when md5 param not exist
-s, --locallimit string rate limit about a single download task, its format is 20M/m/K/k
-m, --md5 string expected file md5
-n, --node strings specify supnernodes
--notbs not back source when p2p fail
-o, --output string output path that not only contains the dir part but also name part
-p, --pattern string download pattern, must be 'p2p' or 'cdn' or 'source'
cdn/source pattern not support 'totallimit' flag (default "p2p")
-b, --showbar show progress bar, it's conflict with '--console'
-e, --timeout int download timeout(second)
--totallimit string rate limit about the whole host, its format is 20M/m/K/k
-u, --url string will download a file from this url
--verbose be verbose
```

### ${HOME}/.small-dragonfly
### SEE ALSO

This directory is created by dfget when you start it for the first time.
* [dfget gen-doc](dfget_gen-doc.md) - Generate Document for dfget command line tool with MarkDown format
* [dfget version](dfget_version.md) - Show the current version

```text
.small-dragonfly/
├── data/ # stores temporary data downloaded by dfget
├── dfdaemon/
│   └── data/ # default, stores temporary data generated by dfdaemon
├── logs/
│   ├── dfclient.log # dfget's log file
│   ├── dfserver.log # log file of peer server launched by dfget
│   └── dfdaemon.log # dfdaemon's log file
└── meta/
└── host.meta # stores meta information: peer server port
```
47 changes: 47 additions & 0 deletions docs/cli_reference/dfget_gen-doc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
## dfget gen-doc

Generate Document for dfget command line tool with MarkDown format

### Synopsis

Generate Document for dfget command line tool with MarkDown format

```
dfget gen-doc [flags]
```

### Options

```
-h, --help help for gen-doc
```

### Options inherited from parent commands

```
--callsystem string system name that executes dfget
--console show log on console, it's conflict with '--showbar'
--dfdaemon caller is from dfdaemon
-f, --filter string filter some query params of url, use char '&' to separate different params
eg: -f 'key&sign' will filter 'key' and 'sign' query param
in this way, different urls correspond one same download task that can use p2p mode
--header strings http header, eg: --header='Accept: *' --header='Host: abc'
-i, --identifier string identify download task, it is available merely when md5 param not exist
-s, --locallimit string rate limit about a single download task, its format is 20M/m/K/k
-m, --md5 string expected file md5
-n, --node strings specify supnernodes
--notbs not back source when p2p fail
-o, --output string output path that not only contains the dir part but also name part
-p, --pattern string download pattern, must be 'p2p' or 'cdn' or 'source'
cdn/source pattern not support 'totallimit' flag (default "p2p")
-b, --showbar show progress bar, it's conflict with '--console'
-e, --timeout int download timeout(second)
--totallimit string rate limit about the whole host, its format is 20M/m/K/k
-u, --url string will download a file from this url
--verbose be verbose
```

### SEE ALSO

* [dfget](dfget.md) - The dfget is the client of Dragonfly.

47 changes: 47 additions & 0 deletions docs/cli_reference/dfget_version.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
## dfget version

Show the current version

### Synopsis

Show the current version

```
dfget version [flags]
```

### Options

```
-h, --help help for version
```

### Options inherited from parent commands

```
--callsystem string system name that executes dfget
--console show log on console, it's conflict with '--showbar'
--dfdaemon caller is from dfdaemon
-f, --filter string filter some query params of url, use char '&' to separate different params
eg: -f 'key&sign' will filter 'key' and 'sign' query param
in this way, different urls correspond one same download task that can use p2p mode
--header strings http header, eg: --header='Accept: *' --header='Host: abc'
-i, --identifier string identify download task, it is available merely when md5 param not exist
-s, --locallimit string rate limit about a single download task, its format is 20M/m/K/k
-m, --md5 string expected file md5
-n, --node strings specify supnernodes
--notbs not back source when p2p fail
-o, --output string output path that not only contains the dir part but also name part
-p, --pattern string download pattern, must be 'p2p' or 'cdn' or 'source'
cdn/source pattern not support 'totallimit' flag (default "p2p")
-b, --showbar show progress bar, it's conflict with '--console'
-e, --timeout int download timeout(second)
--totallimit string rate limit about the whole host, its format is 20M/m/K/k
-u, --url string will download a file from this url
--verbose be verbose
```

### SEE ALSO

* [dfget](dfget.md) - The dfget is the client of Dragonfly.

21 changes: 21 additions & 0 deletions vendor/github.com/cpuguy83/go-md2man/LICENSE.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions vendor/github.com/cpuguy83/go-md2man/md2man/md2man.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f551ff0

Please sign in to comment.