This repository has been archived by the owner on Dec 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 773
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: add gen-doc command to auto gen dfget cli docs
Signed-off-by: Allen Sun <[email protected]>
- Loading branch information
1 parent
a13ad81
commit 9dba3c6
Showing
27 changed files
with
7,370 additions
and
74 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,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") | ||
} |
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,83 +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 | ||
### Options | ||
|
||
This is the default configuration file for dfget, which specifies the address of the supernode. | ||
|
||
```ini | ||
[node] | ||
address=127.0.0.1,127.0.0.2 | ||
``` | ||
--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,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. | ||
|
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,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. | ||
|
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.