This repository was archived by the owner on Dec 20, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 6 files changed +20
-72
lines changed Expand file tree Collapse file tree 6 files changed +20
-72
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ import (
2727 "github.com/dragonflyoss/Dragonfly/dfdaemon"
2828 "github.com/dragonflyoss/Dragonfly/dfdaemon/config"
2929 "github.com/dragonflyoss/Dragonfly/dfdaemon/constant"
30+ "github.com/dragonflyoss/Dragonfly/pkg/cmd"
3031 dferr "github.com/dragonflyoss/Dragonfly/pkg/errortypes"
3132 "github.com/dragonflyoss/Dragonfly/pkg/netutils"
3233 "github.com/dragonflyoss/Dragonfly/pkg/rate"
@@ -105,6 +106,7 @@ func init() {
105106 rf .StringSlice ("node" , nil , "specify the addresses(host:port) of supernodes that will be passed to dfget." )
106107
107108 exitOnError (bindRootFlags (viper .GetViper ()), "bind root command flags" )
109+ rootCmd .AddCommand (cmd .NewGenDocCommand ("dfdaemon" ))
108110}
109111
110112// bindRootFlags binds flags on rootCmd to the given viper instance.
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ import (
2626
2727 "github.com/dragonflyoss/Dragonfly/dfget/config"
2828 "github.com/dragonflyoss/Dragonfly/dfget/core"
29+ "github.com/dragonflyoss/Dragonfly/pkg/cmd"
2930 "github.com/dragonflyoss/Dragonfly/pkg/dflog"
3031 "github.com/dragonflyoss/Dragonfly/pkg/errortypes"
3132 "github.com/dragonflyoss/Dragonfly/pkg/printer"
@@ -67,6 +68,7 @@ var rootCmd = &cobra.Command{
6768
6869func init () {
6970 initFlags ()
71+ rootCmd .AddCommand (cmd .NewGenDocCommand ("dfget" ))
7072}
7173
7274// runDfget does some init operations and starts to download.
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ import (
2323 "reflect"
2424 "time"
2525
26+ "github.com/dragonflyoss/Dragonfly/pkg/cmd"
2627 "github.com/dragonflyoss/Dragonfly/pkg/dflog"
2728 "github.com/dragonflyoss/Dragonfly/pkg/errortypes"
2829 "github.com/dragonflyoss/Dragonfly/pkg/fileutils"
5051 supernodeViper = viper .GetViper ()
5152)
5253
54+ // supernodeDescription is used to describe supernode command in details.
55+ var supernodeDescription = `SuperNode is a long-running process with two primary responsibilities:
56+ It's the tracker and scheduler in the P2P network that choose appropriate downloading net-path for each peer.
57+ It's also a CDN server that caches downloaded data from source to avoid downloading the same files from source repeatedly.`
58+
5359var rootCmd = & cobra.Command {
54- Use : "Dragonfly Supernode" ,
55- Long : "" ,
60+ Use : "supernode" ,
61+ Short : "the central control server of Dragonfly used for scheduling and cdn cache" ,
62+ Long : supernodeDescription ,
5663 Args : cobra .NoArgs ,
5764 SilenceUsage : true ,
5865 RunE : func (cmd * cobra.Command , args []string ) error {
@@ -115,6 +122,7 @@ var rootCmd = &cobra.Command{
115122
116123func init () {
117124 setupFlags (rootCmd )
125+ rootCmd .AddCommand (cmd .NewGenDocCommand ("supernode" ))
118126}
119127
120128// setupFlags setups flags for command line.
Original file line number Diff line number Diff line change @@ -14,9 +14,11 @@ generate-cli-docs(){
1414 CLI_DOCS_DIR=$( cd " ../docs/cli_reference" && pwd)
1515 DFGET_BIN_PATH=../" ${BUILD_PATH} " /dfget
1616 DFDAEMON_BIN_PATH=../" ${BUILD_PATH} " /dfdaemon
17+ SUPERNODE_BIN_PATH=../" ${BUILD_PATH} " /supernode
1718
1819 ${DFGET_BIN_PATH} gen-doc -p " ${CLI_DOCS_DIR} " || return
1920 ${DFDAEMON_BIN_PATH} gen-doc -p " ${CLI_DOCS_DIR} " || return
21+ ${SUPERNODE_BIN_PATH} gen-doc -p " ${CLI_DOCS_DIR} " || return
2022 echo " Generate: CLI docs in ${CLI_DOCS_DIR} "
2123}
2224
Original file line number Diff line number Diff line change 1414 * limitations under the License.
1515 */
1616
17- package app
17+ package cmd
1818
1919import (
2020 "fmt"
@@ -32,11 +32,11 @@ type GenDocCommand struct {
3232 path string
3333}
3434
35- func init () {
35+ func NewGenDocCommand ( name string ) * cobra. Command {
3636 genDocCommand := & GenDocCommand {}
3737 genDocCommand .cmd = & cobra.Command {
3838 Use : "gen-doc" ,
39- Short : "Generate Document for dfget command line tool with MarkDown format" ,
39+ Short : fmt . Sprintf ( "Generate Document for %s command line tool in MarkDown format" , name ) ,
4040 Args : cobra .NoArgs ,
4141 SilenceErrors : true ,
4242 SilenceUsage : true ,
@@ -45,7 +45,7 @@ func init() {
4545 },
4646 }
4747 genDocCommand .addFlags ()
48- rootCmd . AddCommand ( genDocCommand .cmd )
48+ return genDocCommand .cmd
4949}
5050
5151// addFlags adds flags for specific command.
You can’t perform that action at this time.
0 commit comments