forked from dragonflyoss/dragonfly-archived
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request dragonflyoss#312 from allencloud/auto-gen-markdown
feature: add gen-doc command to auto gen dfget cli docs
- Loading branch information
Showing
27 changed files
with
7,332 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
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 | ||
|
||
// path is the destination path of generated markdown documents. | ||
path string | ||
} | ||
|
||
func init() { | ||
genDocCommand := &GenDocCommand{} | ||
genDocCommand.cmd = &cobra.Command{ | ||
Use: "gen-doc", | ||
Short: "Generate Document for dfget command line tool with MarkDown format", | ||
Args: cobra.NoArgs, | ||
SilenceErrors: true, | ||
SilenceUsage: true, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
return genDocCommand.runGenDoc(args) | ||
}, | ||
} | ||
genDocCommand.addFlags() | ||
rootCmd.AddCommand(genDocCommand.cmd) | ||
} | ||
|
||
// addFlags adds flags for specific command. | ||
func (g *GenDocCommand) addFlags() { | ||
flagSet := g.cmd.Flags() | ||
|
||
flagSet.StringVarP(&g.path, "path", "p", "/tmp", "destination path of generated markdown documents") | ||
} | ||
|
||
func (g *GenDocCommand) runGenDoc(args []string) error { | ||
// FIXME: make document path configurable | ||
if _, err := os.Stat(g.path); err != nil { | ||
if os.IsNotExist(err) { | ||
return fmt.Errorf("path %s does not exits, please check your gen-doc input flag --path", g.path) | ||
} | ||
return err | ||
} | ||
return doc.GenMarkdownTree(g.cmd.Parent(), g.path) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
## 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 | ||
-p, --path string destination path of generated markdown documents (default "/tmp") | ||
``` | ||
|
||
### SEE ALSO | ||
|
||
* [dfget](dfget.md) - The dfget is the client of Dragonfly. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
## dfget version | ||
|
||
Show the current version | ||
|
||
### Synopsis | ||
|
||
Show the current version | ||
|
||
``` | ||
dfget version [flags] | ||
``` | ||
|
||
### Options | ||
|
||
``` | ||
-h, --help help for version | ||
``` | ||
|
||
### SEE ALSO | ||
|
||
* [dfget](dfget.md) - The dfget is the client of Dragonfly. | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.