Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update help menus #254

Merged
merged 1 commit into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions cmd/dmsg-discovery/commands/dmsg-discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"net"
"net/http"
"os"
"path/filepath"
"strings"
"time"

Expand Down Expand Up @@ -62,19 +63,24 @@ func init() {
RootCmd.Flags().BoolVar(&enableLoadTesting, "enable-load-testing", false, "enable load testing")
RootCmd.Flags().BoolVar(&testEnvironment, "test-environment", false, "distinguished between prod and test environment")
RootCmd.Flags().Var(&sk, "sk", "dmsg secret key\n")
RootCmd.Flags().Uint16Var(&dmsgPort, "dmsgPort", dmsg.DefaultDmsgHTTPPort, "dmsg port value\r")
RootCmd.Flags().Uint16Var(&dmsgPort, "dmsgPort", dmsg.DefaultDmsgHTTPPort, "dmsg port value")

}

// RootCmd contains commands for dmsg-discovery
var RootCmd = &cobra.Command{
Use: "disc",
Use: func() string {
return strings.Split(filepath.Base(strings.ReplaceAll(strings.ReplaceAll(fmt.Sprintf("%v", os.Args), "[", ""), "]", "")), " ")[0]
}(),
Short: "DMSG Discovery Server",
Long: `
┌┬┐┌┬┐┌─┐┌─┐ ┌┬┐┬┌─┐┌─┐┌─┐┬ ┬┌─┐┬─┐┬ ┬
│││││└─┐│ ┬───│││└─┐│ │ │└┐┌┘├┤ ├┬┘└┬┘
─┴┘┴ ┴└─┘└─┘ ─┴┘┴└─┘└─┘└─┘ └┘ └─┘┴└─ ┴
` + "DMSG Discovery Server",
DMSG Discovery Server
----- depends: redis -----
skywire cli config gen-keys > dmsgd-config.json
skywire dmsg disc --sk $(tail -n1 dmsgd-config.json)`,
SilenceErrors: true,
SilenceUsage: true,
DisableSuggestions: true,
Expand Down
15 changes: 7 additions & 8 deletions cmd/dmsg-discovery/dmsg-discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@ func init() {
}
func main() {
cc.Init(&cc.Config{
RootCmd: commands.RootCmd,
Headings: cc.HiBlue + cc.Bold, //+ cc.Underline,
Commands: cc.HiBlue + cc.Bold,
CmdShortDescr: cc.HiBlue,
Example: cc.HiBlue + cc.Italic,
ExecName: cc.HiBlue + cc.Bold,
Flags: cc.HiBlue + cc.Bold,
//FlagsDataType: cc.HiBlue,
RootCmd: commands.RootCmd,
Headings: cc.HiBlue + cc.Bold,
Commands: cc.HiBlue + cc.Bold,
CmdShortDescr: cc.HiBlue,
Example: cc.HiBlue + cc.Italic,
ExecName: cc.HiBlue + cc.Bold,
Flags: cc.HiBlue + cc.Bold,
FlagsDescr: cc.HiBlue,
NoExtraNewlines: true,
NoBottomNewline: true,
Expand Down
12 changes: 10 additions & 2 deletions cmd/dmsg-server/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
package commands

import (
"fmt"
"log"
"os"
"path/filepath"
"strings"

"github.com/skycoin/skywire-utilities/pkg/buildinfo"
"github.com/spf13/cobra"
Expand All @@ -21,13 +25,17 @@ func init() {

// RootCmd contains the root dmsg-server command
var RootCmd = &cobra.Command{
Use: "server",
Use: func() string {
return strings.Split(filepath.Base(strings.ReplaceAll(strings.ReplaceAll(fmt.Sprintf("%v", os.Args), "[", ""), "]", "")), " ")[0]
}(),
Short: "DMSG Server",
Long: `
┌┬┐┌┬┐┌─┐┌─┐ ┌─┐┌─┐┬─┐┬ ┬┌─┐┬─┐
││││││└─┐│ ┬ ─ └─┐├┤ ├┬┘└┐┌┘├┤ ├┬┘
─┴┘┴ ┴└─┘└─┘ └─┘└─┘┴└─ └┘ └─┘┴└─
` + "DMSG Server",
DMSG Server
skywire dmsg server config gen -o dmsg-config.json
skywire dmsg server start dmsg-config.json`,
SilenceErrors: true,
SilenceUsage: true,
DisableSuggestions: true,
Expand Down
15 changes: 7 additions & 8 deletions cmd/dmsg-server/dmsg-server.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@ func init() {

func main() {
cc.Init(&cc.Config{
RootCmd: commands.RootCmd,
Headings: cc.HiBlue + cc.Bold,
Commands: cc.HiBlue + cc.Bold,
CmdShortDescr: cc.HiBlue,
Example: cc.HiBlue + cc.Italic,
ExecName: cc.HiBlue + cc.Bold,
Flags: cc.HiBlue + cc.Bold,
//FlagsDataType: cc.HiBlue,
RootCmd: commands.RootCmd,
Headings: cc.HiBlue + cc.Bold,
Commands: cc.HiBlue + cc.Bold,
CmdShortDescr: cc.HiBlue,
Example: cc.HiBlue + cc.Italic,
ExecName: cc.HiBlue + cc.Bold,
Flags: cc.HiBlue + cc.Bold,
FlagsDescr: cc.HiBlue,
NoExtraNewlines: true,
NoBottomNewline: true,
Expand Down
23 changes: 19 additions & 4 deletions cmd/dmsg-socks5/commands/dmsg-socks5.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ import (
"net/http"
"os"
"os/signal"
"path/filepath"
"strings"
"time"

socks5 "github.com/confiant-inc/go-socks5"
"github.com/skycoin/skywire-utilities/pkg/buildinfo"
"github.com/skycoin/skywire-utilities/pkg/cipher"
"github.com/skycoin/skywire-utilities/pkg/logging"
"github.com/skycoin/skywire-utilities/pkg/skyenv"
Expand Down Expand Up @@ -61,15 +63,28 @@ func init() {

}

// RootCmd contains the root dmsghttp command
// RootCmd contains the root command
var RootCmd = &cobra.Command{
Use: "proxy",
Use: func() string {
return strings.Split(filepath.Base(strings.ReplaceAll(strings.ReplaceAll(fmt.Sprintf("%v", os.Args), "[", ""), "]", "")), " ")[0]
}(),
Short: "DMSG socks5 proxy server & client",
Long: `
┌┬┐┌┬┐┌─┐┌─┐ ┌─┐┌─┐┌─┐┬┌─┌─┐
│││││└─┐│ ┬───└─┐│ ││ ├┴┐└─┐
─┴┘┴ ┴└─┘└─┘ └─┘└─┘└─┘┴ ┴└─┘
DMSG socks5 proxy server & client`,
SilenceErrors: true,
SilenceUsage: true,
DisableSuggestions: true,
DisableFlagsInUseLine: true,
Version: buildinfo.Version(),
}

// serveCmd serves socks5 over dmsg
var serveCmd = &cobra.Command{
Use: "server",
Short: "dmsg proxy server",
Short: "dmsg socks5 proxy server",
SilenceErrors: true,
SilenceUsage: true,
DisableSuggestions: true,
Expand Down Expand Up @@ -154,7 +169,7 @@ var serveCmd = &cobra.Command{
// proxyCmd serves the local socks5 proxy
var proxyCmd = &cobra.Command{
Use: "client",
Short: "socks5 proxy to connect to socks5 server over dmsg",
Short: "socks5 proxy client for dmsg socks5 proxy server",
Run: func(cmd *cobra.Command, args []string) {
log := logging.MustGetLogger("ssh-proxy-client")
var pubKey cipher.PubKey
Expand Down
15 changes: 7 additions & 8 deletions cmd/dmsg-socks5/dmsg-socks5.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@ func init() {

func main() {
cc.Init(&cc.Config{
RootCmd: commands.RootCmd,
Headings: cc.HiBlue + cc.Bold,
Commands: cc.HiBlue + cc.Bold,
CmdShortDescr: cc.HiBlue,
Example: cc.HiBlue + cc.Italic,
ExecName: cc.HiBlue + cc.Bold,
Flags: cc.HiBlue + cc.Bold,
//FlagsDataType: cc.HiBlue,
RootCmd: commands.RootCmd,
Headings: cc.HiBlue + cc.Bold,
Commands: cc.HiBlue + cc.Bold,
CmdShortDescr: cc.HiBlue,
Example: cc.HiBlue + cc.Italic,
ExecName: cc.HiBlue + cc.Bold,
Flags: cc.HiBlue + cc.Bold,
FlagsDescr: cc.HiBlue,
NoExtraNewlines: true,
NoBottomNewline: true,
Expand Down
24 changes: 20 additions & 4 deletions cmd/dmsg/dmsg.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ package main

import (
"fmt"
"os"
"path/filepath"
"strings"

cc "github.com/ivanpirog/coloredcobra"
"github.com/spf13/cobra"

dmsgdisc "github.com/skycoin/dmsg/cmd/dmsg-discovery/commands"
dmsgserver "github.com/skycoin/dmsg/cmd/dmsg-server/commands"
dmsgsocks "github.com/skycoin/dmsg/cmd/dmsg-socks5/commands"
dmsgcurl "github.com/skycoin/dmsg/cmd/dmsgcurl/commands"
dmsghttp "github.com/skycoin/dmsg/cmd/dmsghttp/commands"
dmsgptycli "github.com/skycoin/dmsg/cmd/dmsgpty-cli/commands"
Expand All @@ -23,15 +27,25 @@ func init() {
dmsgptyhost.RootCmd,
dmsgptyui.RootCmd,
)
dmsgcurl.RootCmd.Use = "curl [OPTIONS] ... [URL]"
RootCmd.AddCommand(
dmsgptyCmd,
dmsgdisc.RootCmd,
dmsgserver.RootCmd,
dmsghttp.RootCmd,
dmsgcurl.RootCmd,
dmsgweb.RootCmd,
dmsgsocks.RootCmd,
)
dmsgdisc.RootCmd.Use = "disc"
dmsgserver.RootCmd.Use = "server"
dmsghttp.RootCmd.Use = "http"
dmsgcurl.RootCmd.Use = "curl"
dmsgweb.RootCmd.Use = "web"
dmsgsocks.RootCmd.Use = "socks"
dmsgptycli.RootCmd.Use = "cli"
dmsgptyhost.RootCmd.Use = "host"
dmsgptyui.RootCmd.Use = "ui"

var helpflag bool
RootCmd.SetUsageTemplate(help)
RootCmd.PersistentFlags().BoolVarP(&helpflag, "help", "h", false, "help for dmsg")
Expand All @@ -43,13 +57,15 @@ func init() {

// RootCmd contains all binaries which may be separately compiled as subcommands
var RootCmd = &cobra.Command{
Use: "dmsg",
Use: func() string {
return strings.Split(filepath.Base(strings.ReplaceAll(strings.ReplaceAll(fmt.Sprintf("%v", os.Args), "[", ""), "]", "")), " ")[0]
}(),
Short: "DMSG services & utilities",
Long: `
┌┬┐┌┬┐┌─┐┌─┐
│││││└─┐│ ┬
─┴┘┴ ┴└─┘└─┘
` + "DMSG services & utilities",
DMSG services & utilities`,
SilenceErrors: true,
SilenceUsage: true,
DisableSuggestions: true,
Expand All @@ -63,7 +79,7 @@ var dmsgptyCmd = &cobra.Command{
┌─┐┌┬┐┬ ┬
├─┘ │ └┬┘
┴ ┴ ┴
` + "DMSG pseudoterminal (pty)",
DMSG pseudoterminal (pty)`,
SilenceErrors: true,
SilenceUsage: true,
DisableSuggestions: true,
Expand Down
6 changes: 4 additions & 2 deletions cmd/dmsgcurl/commands/dmsgcurl.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,15 @@ func init() {

// RootCmd containsa the root dmsgcurl command
var RootCmd = &cobra.Command{
Use: func() string {
return strings.Split(filepath.Base(strings.ReplaceAll(strings.ReplaceAll(fmt.Sprintf("%v", os.Args), "[", ""), "]", "")), " ")[0]
}(),
Short: "DMSG curl utility",
Use: "dmsgcurl [OPTIONS] ... [URL]",
Long: `
┌┬┐┌┬┐┌─┐┌─┐┌─┐┬ ┬┬─┐┬
│││││└─┐│ ┬│ │ │├┬┘│
─┴┘┴ ┴└─┘└─┘└─┘└─┘┴└─┴─┘
` + "DMSG curl utility",
DMSG curl utility`,
SilenceErrors: true,
SilenceUsage: true,
DisableSuggestions: true,
Expand Down
15 changes: 7 additions & 8 deletions cmd/dmsgcurl/dmsgcurl.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@ func init() {

func main() {
cc.Init(&cc.Config{
RootCmd: commands.RootCmd,
Headings: cc.HiBlue + cc.Bold,
Commands: cc.HiBlue + cc.Bold,
CmdShortDescr: cc.HiBlue,
Example: cc.HiBlue + cc.Italic,
ExecName: cc.HiBlue + cc.Bold,
Flags: cc.HiBlue + cc.Bold,
//FlagsDataType: cc.HiBlue,
RootCmd: commands.RootCmd,
Headings: cc.HiBlue + cc.Bold,
Commands: cc.HiBlue + cc.Bold,
CmdShortDescr: cc.HiBlue,
Example: cc.HiBlue + cc.Italic,
ExecName: cc.HiBlue + cc.Bold,
Flags: cc.HiBlue + cc.Bold,
FlagsDescr: cc.HiBlue,
NoExtraNewlines: true,
NoBottomNewline: true,
Expand Down
6 changes: 4 additions & 2 deletions cmd/dmsghttp/commands/dmsghttp.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,15 @@ func init() {

// RootCmd contains the root dmsghttp command
var RootCmd = &cobra.Command{
Use: "http",
Use: func() string {
return strings.Split(filepath.Base(strings.ReplaceAll(strings.ReplaceAll(fmt.Sprintf("%v", os.Args), "[", ""), "]", "")), " ")[0]
}(),
Short: "DMSG http file server",
Long: `
┌┬┐┌┬┐┌─┐┌─┐┬ ┬┌┬┐┌┬┐┌─┐
│││││└─┐│ ┬├─┤ │ │ ├─┘
─┴┘┴ ┴└─┘└─┘┴ ┴ ┴ ┴ ┴
` + "DMSG http file server",
DMSG http file server`,
SilenceErrors: true,
SilenceUsage: true,
DisableSuggestions: true,
Expand Down
15 changes: 7 additions & 8 deletions cmd/dmsghttp/dmsghttp.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@ func init() {

func main() {
cc.Init(&cc.Config{
RootCmd: commands.RootCmd,
Headings: cc.HiBlue + cc.Bold, //+ cc.Underline,
Commands: cc.HiBlue + cc.Bold,
CmdShortDescr: cc.HiBlue,
Example: cc.HiBlue + cc.Italic,
ExecName: cc.HiBlue + cc.Bold,
Flags: cc.HiBlue + cc.Bold,
//FlagsDataType: cc.HiBlue,
RootCmd: commands.RootCmd,
Headings: cc.HiBlue + cc.Bold,
Commands: cc.HiBlue + cc.Bold,
CmdShortDescr: cc.HiBlue,
Example: cc.HiBlue + cc.Italic,
ExecName: cc.HiBlue + cc.Bold,
Flags: cc.HiBlue + cc.Bold,
FlagsDescr: cc.HiBlue,
NoExtraNewlines: true,
NoBottomNewline: true,
Expand Down
9 changes: 7 additions & 2 deletions cmd/dmsgpty-cli/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ package commands
import (
"context"
"encoding/json"
"fmt"
"log"
"os"
"path/filepath"
"strings"

"github.com/skycoin/skywire-utilities/pkg/buildinfo"
"github.com/skycoin/skywire-utilities/pkg/cmdutil"
Expand Down Expand Up @@ -39,13 +42,15 @@ func init() {

// RootCmd contains commands for dmsgpty-cli; which interacts with the dmsgpty-host instance (i.e. skywire-visor)
var RootCmd = &cobra.Command{
Use: "cli",
Use: func() string {
return strings.Split(filepath.Base(strings.ReplaceAll(strings.ReplaceAll(fmt.Sprintf("%v", os.Args), "[", ""), "]", "")), " ")[0]
}(),
Short: "DMSG pseudoterminal command line interface",
Long: `
┌┬┐┌┬┐┌─┐┌─┐┌─┐┌┬┐┬ ┬ ┌─┐┬ ┬
│││││└─┐│ ┬├─┘ │ └┬┘───│ │ │
─┴┘┴ ┴└─┘└─┘┴ ┴ ┴ └─┘┴─┘┴
` + "DMSG pseudoterminal command line interface",
DMSG pseudoterminal command line interface`,
SilenceErrors: true,
SilenceUsage: true,
DisableSuggestions: true,
Expand Down
15 changes: 7 additions & 8 deletions cmd/dmsgpty-cli/dmsgpty-cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@ func init() {

func main() {
cc.Init(&cc.Config{
RootCmd: commands.RootCmd,
Headings: cc.HiBlue + cc.Bold, //+ cc.Underline,
Commands: cc.HiBlue + cc.Bold,
CmdShortDescr: cc.HiBlue,
Example: cc.HiBlue + cc.Italic,
ExecName: cc.HiBlue + cc.Bold,
Flags: cc.HiBlue + cc.Bold,
//FlagsDataType: cc.HiBlue,
RootCmd: commands.RootCmd,
Headings: cc.HiBlue + cc.Bold,
Commands: cc.HiBlue + cc.Bold,
CmdShortDescr: cc.HiBlue,
Example: cc.HiBlue + cc.Italic,
ExecName: cc.HiBlue + cc.Bold,
Flags: cc.HiBlue + cc.Bold,
FlagsDescr: cc.HiBlue,
NoExtraNewlines: true,
NoBottomNewline: true,
Expand Down
Loading
Loading