-
-
Notifications
You must be signed in to change notification settings - Fork 93
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 #839 from sunny0826/feat/docs
feat: 🎸 add docs command
- Loading branch information
Showing
15 changed files
with
62 additions
and
1 deletion.
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
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
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
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"github.com/pkg/browser" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
type DocsCommand struct { | ||
BaseCommand | ||
} | ||
|
||
var DOCS = "https://kubecm.cloud/" | ||
|
||
// Init DocsCommand | ||
func (dc *DocsCommand) Init() { | ||
dc.command = &cobra.Command{ | ||
Use: "docs", | ||
Short: "Open document website", | ||
Long: "Open document website in your browser", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
return dc.runDocs(cmd, args) | ||
}, | ||
Example: docsExample(), | ||
} | ||
} | ||
|
||
func (dc *DocsCommand) runDocs(cmd *cobra.Command, args []string) error { | ||
var url string | ||
if cmd.Parent().Use == "kubecm" { | ||
url = DOCS | ||
} else { | ||
url = fmt.Sprintf("%s#/en-us/cli/kubecm_%s", DOCS, cmd.Parent().Use) | ||
} | ||
fmt.Printf("Opened %s in your browser.\n", url) | ||
return browser.OpenURL(url) | ||
} | ||
|
||
func docsExample() string { | ||
return ` | ||
# Open kubecm website | ||
kubecm docs | ||
# Open add command document page | ||
kubecm add docs | ||
` | ||
} |
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
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
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
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