Skip to content

Commit

Permalink
Merge pull request #236 from jameskim0987/issue-227-add-docs-cli-flag
Browse files Browse the repository at this point in the history
[ISSUE-227] add `docs` CLI command
  • Loading branch information
jakim929 authored Nov 5, 2024
2 parents 661a6f3 + 1a99cb7 commit 5084529
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ func main() {
Flags: append(config.ForkCLIFlags(envVarPrefix), baseFlags...),
Action: cliapp.LifecycleCmd(SupersimMain),
},
{
Name: config.DocsCommandName,
Usage: "Display available docs links",
Action: cliapp.LifecycleCmd(SupersimMain),
},
}

ctx := ctxinterrupt.WithSignalWaiterMain(context.Background())
Expand All @@ -89,6 +94,12 @@ func SupersimMain(ctx *cli.Context, closeApp context.CancelCauseFunc) (cliapp.Li
return nil, fmt.Errorf("invalid cli config: %w", err)
}

if ctx.Command.Name == config.DocsCommandName {
config.PrintDocLinks()
closeApp(nil)
os.Exit(0)
}

// use config and setup supersim
s, err := supersim.NewSupersim(log, envVarPrefix, closeApp, cfg)
if err != nil {
Expand Down
18 changes: 18 additions & 0 deletions config/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

const (
ForkCommandName = "fork"
DocsCommandName = "docs"

AdminPortFlagName = "admin.port"

Expand All @@ -29,6 +30,15 @@ const (
InteropAutoRelayFlagName = "interop.autorelay"
)

var documentationLinks = []struct {
url string
text string
}{
{"https://specs.optimism.io/interop/overview.html", "Superchain Interop Specs"},
{"https://docs.optimism.io/", "Optimism Documentation"},
{"https://supersim.pages.dev/", "Supersim Documentation"},
}

func BaseCLIFlags(envPrefix string) []cli.Flag {
return []cli.Flag{
&cli.Uint64Flag{
Expand Down Expand Up @@ -167,3 +177,11 @@ func (c *CLIConfig) Check() error {

return nil
}

func PrintDocLinks() {
fmt.Printf("Here are the available documentation links:\n\n")

for _, link := range documentationLinks {
fmt.Printf("\033]8;;%s\033\\%s\033]8;;\033\\\n", link.url, link.text)
}
}

0 comments on commit 5084529

Please sign in to comment.