diff --git a/commands/legacy/legacy.go b/commands/legacy/legacy.go index de44d7bda..513c16496 100644 --- a/commands/legacy/legacy.go +++ b/commands/legacy/legacy.go @@ -45,6 +45,8 @@ func (me *MarshalerEncoder) Encode(v interface{}) error { return err } +// OldContext tries to cast the environment as a legacy command context, +// returning nil on failure. func OldContext(env interface{}) *oldcmds.Context { ctx, ok := env.(*oldcmds.Context) if !ok { diff --git a/core/corehttp/commands.go b/core/corehttp/commands.go index b25a96b33..60be1b1f7 100644 --- a/core/corehttp/commands.go +++ b/core/corehttp/commands.go @@ -134,10 +134,14 @@ func commandsOption(cctx oldcmds.Context, command *cmds.Command) ServeOption { } } +// CommandsOption constructs a ServerOption for hooking the commands into the +// HTTP server. func CommandsOption(cctx oldcmds.Context) ServeOption { return commandsOption(cctx, corecommands.Root) } +// CommandsOption constructs a ServerOption for hooking the read-only commands +// into the HTTP server. func CommandsROOption(cctx oldcmds.Context) ServeOption { return commandsOption(cctx, corecommands.RootRO) }