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

[ISSUE-227] add docs CLI command #236

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
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)
}
}
Loading