Skip to content

Commit

Permalink
add dependencies and setup instructions for core services to help menus
Browse files Browse the repository at this point in the history
  • Loading branch information
0pcom committed Mar 6, 2024
1 parent c9e98dd commit be400e6
Show file tree
Hide file tree
Showing 17 changed files with 157 additions and 24 deletions.
43 changes: 41 additions & 2 deletions cmd/address-resolver/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ import (
"log"
"log/syslog"
"os"
"path/filepath"
"strings"
"time"

cc "github.com/ivanpirog/coloredcobra"
logrussyslog "github.com/sirupsen/logrus/hooks/syslog"
"github.com/skycoin/dmsg/pkg/direct"
"github.com/skycoin/dmsg/pkg/dmsg"
Expand Down Expand Up @@ -66,16 +68,30 @@ func init() {
RootCmd.Flags().BoolVar(&testEnvironment, "test-environment", false, "distinguished between prod and test environment\033[0m")
RootCmd.Flags().Var(&sk, "sk", "dmsg secret key\r")
RootCmd.Flags().Uint16Var(&dmsgPort, "dmsgPort", dmsg.DefaultDmsgHTTPPort, "dmsg port value\r")
var helpflag bool
RootCmd.SetUsageTemplate(help)
RootCmd.PersistentFlags().BoolVarP(&helpflag, "help", "h", false, "help for address-resolver")
RootCmd.SetHelpCommand(&cobra.Command{Hidden: true})
RootCmd.PersistentFlags().MarkHidden("help") //nolint
}

// RootCmd contains the root command
var RootCmd = &cobra.Command{
Use: "ar",
Use: func() string {
return strings.Split(filepath.Base(strings.ReplaceAll(strings.ReplaceAll(fmt.Sprintf("%v", os.Args), "[", ""), "]", "")), " ")[0]
}(),
Short: "Address Resolver Server for skywire",
Long: `
┌─┐┌┬┐┌┬┐┬─┐┌─┐┌─┐┌─┐ ┬─┐┌─┐┌─┐┌─┐┬ ┬ ┬┌─┐┬─┐
├─┤ ││ ││├┬┘├┤ └─┐└─┐───├┬┘├┤ └─┐│ ││ └┐┌┘├┤ ├┬┘
┴ ┴─┴┘─┴┘┴└─└─┘└─┘└─┘ ┴└─└─┘└─┘└─┘┴─┘└┘ └─┘┴└─`,
┴ ┴─┴┘─┴┘┴└─└─┘└─┘└─┘ ┴└─└─┘└─┘└─┘┴─┘└┘ └─┘┴└─
depends: redis
Note: the specified port must be accessible from the internet ip address or port forwarded for udp
skywire cli config gen-keys > ar-config.json
skywire svc ar --addr ":9093" --redis "redis://localhost:6379" --sk $(tail -n1 ar-config.json)
`,
SilenceErrors: true,
SilenceUsage: true,
DisableSuggestions: true,
Expand Down Expand Up @@ -227,8 +243,31 @@ var RootCmd = &cobra.Command{

// Execute executes root CLI command.
func Execute() {
cc.Init(&cc.Config{
RootCmd: 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,
FlagsDescr: cc.HiBlue,
NoExtraNewlines: true,
NoBottomNewline: true,
})
if err := RootCmd.Execute(); err != nil {
log.Fatal("Failed to execute command: ", err)

}
}

const help = "Usage:\r\n" +
" {{.UseLine}}{{if .HasAvailableSubCommands}}{{end}} {{if gt (len .Aliases) 0}}\r\n\r\n" +
"{{.NameAndAliases}}{{end}}{{if .HasAvailableSubCommands}}\r\n\r\n" +
"Available Commands:{{range .Commands}}{{if (or .IsAvailableCommand)}}\r\n " +
"{{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableLocalFlags}}\r\n\r\n" +
"Flags:\r\n" +
"{{.LocalFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasAvailableInheritedFlags}}\r\n\r\n" +
"Global Flags:\r\n" +
"{{.InheritedFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}\r\n\r\n"
6 changes: 5 additions & 1 deletion cmd/config-bootstrapper/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"io"
"log"
"os"
"path/filepath"
"strings"

"github.com/skycoin/dmsg/pkg/direct"
"github.com/skycoin/dmsg/pkg/dmsg"
Expand Down Expand Up @@ -44,7 +46,9 @@ func init() {

// RootCmd contains the root command
var RootCmd = &cobra.Command{
Use: "cb",
Use: func() string {
return strings.Split(filepath.Base(strings.ReplaceAll(strings.ReplaceAll(fmt.Sprintf("%v", os.Args), "[", ""), "]", "")), " ")[0]
}(),
Short: "Config Bootstrap Server for skywire",
Long: `
┌─┐┌─┐┌┐┌┌─┐┬┌─┐ ┌┐ ┌─┐┌─┐┌┬┐┌─┐┌┬┐┬─┐┌─┐┌─┐┌─┐┌─┐┬─┐
Expand Down
12 changes: 9 additions & 3 deletions cmd/dmsg-monitor/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ package commands

import (
"context"
"fmt"
"log"
"log/syslog"
"os"
"path/filepath"
"strings"
"time"

logrussyslog "github.com/sirupsen/logrus/hooks/syslog"
Expand Down Expand Up @@ -45,12 +48,15 @@ func init() {

// RootCmd contains the root command
var RootCmd = &cobra.Command{
Use: "mon",
Short: "DMSG monitor of DMSG discoery.",
Use: func() string {
return strings.Split(filepath.Base(strings.ReplaceAll(strings.ReplaceAll(fmt.Sprintf("%v", os.Args), "[", ""), "]", "")), " ")[0]
}(),
Short: "DMSG monitor of DMSG discovery entries.",
Long: `
┌┬┐┌┬┐┌─┐┌─┐ ┌┬┐┌─┐┌┐┌┬┌┬┐┌─┐┬─┐
│││││└─┐│ ┬───││││ │││││ │ │ │├┬┘
─┴┘┴ ┴└─┘└─┘ ┴ ┴└─┘┘└┘┴ ┴ └─┘┴└─`,
─┴┘┴ ┴└─┘└─┘ ┴ ┴└─┘┘└┘┴ ┴ └─┘┴└─
`,
SilenceErrors: true,
SilenceUsage: true,
DisableSuggestions: true,
Expand Down
7 changes: 6 additions & 1 deletion cmd/keys-gen/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ package commands
import (
"fmt"
"log"
"os"
"path/filepath"
"strings"

"github.com/skycoin/skywire-utilities/pkg/buildinfo"
"github.com/skycoin/skywire-utilities/pkg/cipher"
Expand All @@ -12,7 +15,9 @@ import (

// RootCmd contains the root command
var RootCmd = &cobra.Command{
Use: "kg",
Use: func() string {
return strings.Split(filepath.Base(strings.ReplaceAll(strings.ReplaceAll(fmt.Sprintf("%v", os.Args), "[", ""), "]", "")), " ")[0]
}(),
Short: "skywire keys generator, prints pub-key and sec-key",
Long: `
┬┌─┌─┐┬ ┬┌─┐ ┌─┐┌─┐┌┐┌
Expand Down
6 changes: 5 additions & 1 deletion cmd/liveness-checker/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ package commands

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

logrussyslog "github.com/sirupsen/logrus/hooks/syslog"
Expand Down Expand Up @@ -46,7 +48,9 @@ func init() {

// RootCmd contains the root command
var RootCmd = &cobra.Command{
Use: "lc",
Use: func() string {
return strings.Split(filepath.Base(strings.ReplaceAll(strings.ReplaceAll(fmt.Sprintf("%v", os.Args), "[", ""), "]", "")), " ")[0]
}(),
Short: "Liveness checker of the deployment.",
Long: `
┬ ┬┬ ┬┌─┐┌┐┌┌─┐┌─┐┌─┐ ┌─┐┬ ┬┌─┐┌─┐┬┌─┌─┐┬─┐
Expand Down
6 changes: 5 additions & 1 deletion cmd/network-monitor/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ package commands

import (
"context"
"fmt"
"log"
"log/syslog"
"os"
"path/filepath"
"strings"
"time"

Expand Down Expand Up @@ -64,7 +66,9 @@ func init() {

// RootCmd contains the root command
var RootCmd = &cobra.Command{
Use: "mn",
Use: func() string {
return strings.Split(filepath.Base(strings.ReplaceAll(strings.ReplaceAll(fmt.Sprintf("%v", os.Args), "[", ""), "]", "")), " ")[0]
}(),
Short: "Network monitor for skywire VPN and Visor.",
Long: `
┌┐┌┌─┐┌┬┐┬ ┬┌─┐┬─┐┬┌─ ┌┬┐┌─┐┌┐┌┬┌┬┐┌─┐┬─┐
Expand Down
7 changes: 6 additions & 1 deletion cmd/node-visualizer/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ package commands

import (
"context"
"fmt"
"log"
"log/syslog"
"net/http"
"os"
"path/filepath"
"strings"
"time"

logrussyslog "github.com/sirupsen/logrus/hooks/syslog"
Expand Down Expand Up @@ -40,7 +43,9 @@ func init() {

// RootCmd contains the root command
var RootCmd = &cobra.Command{
Use: "nv",
Use: func() string {
return strings.Split(filepath.Base(strings.ReplaceAll(strings.ReplaceAll(fmt.Sprintf("%v", os.Args), "[", ""), "]", "")), " ")[0]
}(),
Short: "Node Visualizer Server for skywire",
Long: `
┌┐┌┌─┐┌┬┐┌─┐ ┬ ┬┬┌─┐┬ ┬┌─┐┬ ┬┌─┐┌─┐┬─┐
Expand Down
7 changes: 6 additions & 1 deletion cmd/public-visor-monitor/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ package commands

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

"github.com/skycoin/skywire-utilities/pkg/buildinfo"
Expand Down Expand Up @@ -35,7 +38,9 @@ func init() {

// RootCmd contains the root command
var RootCmd = &cobra.Command{
Use: "pvm",
Use: func() string {
return strings.Split(filepath.Base(strings.ReplaceAll(strings.ReplaceAll(fmt.Sprintf("%v", os.Args), "[", ""), "]", "")), " ")[0]
}(),
Short: "Public Visor monitor.",
Long: `
┌─┐┬ ┬┌┐ ┬ ┬┌─┐ ┬ ┬┬┌─┐┌─┐┬─┐ ┌┬┐┌─┐┌┐┌┬┌┬┐┌─┐┬─┐
Expand Down
12 changes: 10 additions & 2 deletions cmd/route-finder/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"log"
"log/syslog"
"os"
"path/filepath"
"strings"
"time"

logrussyslog "github.com/sirupsen/logrus/hooks/syslog"
Expand Down Expand Up @@ -58,12 +60,18 @@ func init() {

// RootCmd contains the root command
var RootCmd = &cobra.Command{
Use: "rf",
Use: func() string {
return strings.Split(filepath.Base(strings.ReplaceAll(strings.ReplaceAll(fmt.Sprintf("%v", os.Args), "[", ""), "]", "")), " ")[0]
}(),
Short: "Route Finder Server for skywire",
Long: `
┬─┐┌─┐┬ ┬┌┬┐┌─┐ ┌─┐┬┌┐┌┌┬┐┌─┐┬─┐
├┬┘│ ││ │ │ ├┤───├┤ ││││ ││├┤ ├┬┘
┴└─└─┘└─┘ ┴ └─┘ └ ┴┘└┘─┴┘└─┘┴└─`,
┴└─└─┘└─┘ ┴ └─┘ └ ┴┘└┘─┴┘└─┘┴└─
----- depends: postgres and initial db setup -----
sudo -iu postgres createdb rf
skywire cli config gen-keys | tee rf-config.json
PG_USER="postgres" PG_DATABASE="rf" PG_PASSWORD="" route-finder --addr ":9092" --sk $(tail -n1 rf-config.json)`,
SilenceErrors: true,
SilenceUsage: true,
DisableSuggestions: true,
Expand Down
7 changes: 6 additions & 1 deletion cmd/skysocks-monitor/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ package commands

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

"github.com/skycoin/skywire-utilities/pkg/buildinfo"
Expand Down Expand Up @@ -33,7 +36,9 @@ func init() {

// RootCmd contains the root command
var RootCmd = &cobra.Command{
Use: "skysocksmon",
Use: func() string {
return strings.Split(filepath.Base(strings.ReplaceAll(strings.ReplaceAll(fmt.Sprintf("%v", os.Args), "[", ""), "]", "")), " ")[0]
}(),
Short: "Skysocks monitor.",
Long: `
┌─┐┬┌─┬ ┬┌─┐┌─┐┌─┐┬┌─┌─┐ ┌┬┐┌─┐┌┐┌┬┌┬┐┌─┐┬─┐
Expand Down
24 changes: 21 additions & 3 deletions cmd/skywire-services/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ package main

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

cc "github.com/ivanpirog/coloredcobra"
"github.com/skycoin/skywire-utilities/pkg/buildinfo"
Expand Down Expand Up @@ -37,6 +40,18 @@ func init() {
se.RootCmd,
dmsgm.RootCmd,
)
tpd.RootCmd.Use = "tpd"
tps.RootCmd.Use = "tps"
tpdm.RootCmd.Use = "tpdm"
ar.RootCmd.Use = "ar"
rf.RootCmd.Use = "rf"
confbs.RootCmd.Use = "confbs"
kg.RootCmd.Use = "kg"
lc.RootCmd.Use = "lc"
nv.RootCmd.Use = "nv"
pvm.RootCmd.Use = "pvm"
se.RootCmd.Use = "se"
dmsgm.RootCmd.Use = "dmsgm"

var helpflag bool
RootCmd.SetUsageTemplate(help)
Expand All @@ -49,7 +64,9 @@ func init() {

// RootCmd contains all subcommands
var RootCmd = &cobra.Command{
Use: "svc",
Use: func() string {
return strings.Split(filepath.Base(strings.ReplaceAll(strings.ReplaceAll(fmt.Sprintf("%v", os.Args), "[", ""), "]", "")), " ")[0]
}(),
Short: "Skywire services",
Long: `
┌─┐┬┌─┬ ┬┬ ┬┬┬─┐┌─┐ ┌─┐┌─┐┬─┐┬ ┬┬┌─┐┌─┐┌─┐
Expand Down Expand Up @@ -80,8 +97,9 @@ func main() {
}
}

const help = "{{if gt (len .Aliases) 0}}" +
"{{.NameAndAliases}}{{end}}{{if .HasAvailableSubCommands}}" +
const help = "Usage:\r\n" +
" {{.UseLine}}{{if .HasAvailableSubCommands}}{{end}} {{if gt (len .Aliases) 0}}\r\n\r\n" +
"{{.NameAndAliases}}{{end}}{{if .HasAvailableSubCommands}}\r\n\r\n" +
"Available Commands:{{range .Commands}}{{if (or .IsAvailableCommand)}}\r\n " +
"{{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableLocalFlags}}\r\n\r\n" +
"Flags:\r\n" +
Expand Down
7 changes: 6 additions & 1 deletion cmd/sw-env/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ package commands
import (
"fmt"
"log"
"os"
"path/filepath"
"strings"

"github.com/skycoin/skywire-utilities/pkg/buildinfo"
"github.com/spf13/cobra"
Expand All @@ -13,7 +16,9 @@ import (

// RootCmd contains the root command
var RootCmd = &cobra.Command{
Use: "swe",
Use: func() string {
return strings.Split(filepath.Base(strings.ReplaceAll(strings.ReplaceAll(fmt.Sprintf("%v", os.Args), "[", ""), "]", "")), " ")[0]
}(),
Short: "skywire environment generator",
Long: `
┌─┐┬ ┬ ┌─┐┌┐┌┬ ┬
Expand Down
7 changes: 6 additions & 1 deletion cmd/tpd-monitor/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ package commands

import (
"context"
"fmt"
"log"
"log/syslog"
"os"
"path/filepath"
"strings"
"time"

logrussyslog "github.com/sirupsen/logrus/hooks/syslog"
Expand Down Expand Up @@ -45,7 +48,9 @@ func init() {

// RootCmd contains the root command
var RootCmd = &cobra.Command{
Use: "tpdm",
Use: func() string {
return strings.Split(filepath.Base(strings.ReplaceAll(strings.ReplaceAll(fmt.Sprintf("%v", os.Args), "[", ""), "]", "")), " ")[0]
}(),
Short: "TPD monitor of transport discovery.",
Long: `
┌┬┐┌─┐┌┬┐ ┌┬┐┌─┐┌┐┌┬┌┬┐┌─┐┬─┐
Expand Down
Loading

0 comments on commit be400e6

Please sign in to comment.