TUN-3395: Unhide named tunnel subcommands, tweak help

This commit is contained in:
Igor Postelnik 2020-09-14 17:23:23 -05:00
parent 55346444c9
commit c52e0dc8ef
1 changed files with 16 additions and 24 deletions

View File

@ -80,15 +80,12 @@ var (
} }
) )
const hideSubcommands = true
func buildCreateCommand() *cli.Command { func buildCreateCommand() *cli.Command {
return &cli.Command{ return &cli.Command{
Name: "create", Name: "create",
Action: cliutil.ErrorHandler(createCommand), Action: cliutil.ErrorHandler(createCommand),
Usage: "Create a new tunnel with given name", Usage: "Create a new tunnel with given name",
ArgsUsage: "TUNNEL-NAME", ArgsUsage: "TUNNEL-NAME",
Hidden: hideSubcommands,
Flags: []cli.Flag{outputFormatFlag}, Flags: []cli.Flag{outputFormatFlag},
} }
} }
@ -153,7 +150,6 @@ func buildListCommand() *cli.Command {
Action: cliutil.ErrorHandler(listCommand), Action: cliutil.ErrorHandler(listCommand),
Usage: "List existing tunnels", Usage: "List existing tunnels",
ArgsUsage: " ", ArgsUsage: " ",
Hidden: hideSubcommands,
Flags: []cli.Flag{outputFormatFlag, showDeletedFlag, listNameFlag, listExistedAtFlag, listIDFlag, showRecentlyDisconnected}, Flags: []cli.Flag{outputFormatFlag, showDeletedFlag, listNameFlag, listExistedAtFlag, listIDFlag, showRecentlyDisconnected},
} }
} }
@ -209,6 +205,7 @@ func fmtAndPrintTunnelList(tunnels []*tunnelstore.Tunnel, showRecentlyDisconnect
) )
writer := tabwriter.NewWriter(os.Stdout, minWidth, tabWidth, padding, padChar, flags) writer := tabwriter.NewWriter(os.Stdout, minWidth, tabWidth, padding, padChar, flags)
defer writer.Flush()
// Print column headers with tabbed columns // Print column headers with tabbed columns
fmt.Fprintln(writer, "ID\tNAME\tCREATED\tCONNECTIONS\t") fmt.Fprintln(writer, "ID\tNAME\tCREATED\tCONNECTIONS\t")
@ -224,9 +221,6 @@ func fmtAndPrintTunnelList(tunnels []*tunnelstore.Tunnel, showRecentlyDisconnect
) )
fmt.Fprintln(writer, formattedStr) fmt.Fprintln(writer, formattedStr)
} }
// Write data buffered in tabwriter to output
writer.Flush()
} }
func fmtConnections(connections []tunnelstore.Connection, showRecentlyDisconnected bool) string { func fmtConnections(connections []tunnelstore.Connection, showRecentlyDisconnected bool) string {
@ -258,9 +252,8 @@ func buildDeleteCommand() *cli.Command {
return &cli.Command{ return &cli.Command{
Name: "delete", Name: "delete",
Action: cliutil.ErrorHandler(deleteCommand), Action: cliutil.ErrorHandler(deleteCommand),
Usage: "Delete existing tunnel with given IDs", Usage: "Delete existing tunnel by UUID or name",
ArgsUsage: "TUNNEL-ID", ArgsUsage: "TUNNEL",
Hidden: hideSubcommands,
Flags: []cli.Flag{credentialsFileFlag, forceDeleteFlag}, Flags: []cli.Flag{credentialsFileFlag, forceDeleteFlag},
} }
} }
@ -301,12 +294,13 @@ func buildRunCommand() *cli.Command {
Name: "run", Name: "run",
Action: cliutil.ErrorHandler(runCommand), Action: cliutil.ErrorHandler(runCommand),
Usage: "Proxy a local web server by running the given tunnel", Usage: "Proxy a local web server by running the given tunnel",
ArgsUsage: "TUNNEL-ID", ArgsUsage: "TUNNEL",
Description: "Runs the tunnel, creating a high-availability connection between your server and the Cloudflare " + Description: `Runs the tunnel identified by name or UUUD, creating a highly available connection
"edge. This command requires the tunnel credentials file created when `cloudflared tunnel create` was run, but " + between your server and the Cloudflare edge.
"does not require the cert.pem from `cloudflared login`. If you experience problems running the tunnel, " +
"`cloudflared tunnel cleanup` may help by removing any old connection records.", This command requires the tunnel credentials file created when "cloudflared tunnel create" was run,
Hidden: hideSubcommands, however it does not need access to cert.pem from "cloudflared login". If you experience problems running
the tunnel, "cloudflared tunnel cleanup" may help by removing any old connection records.`,
Flags: []cli.Flag{forceFlag, credentialsFileFlag}, Flags: []cli.Flag{forceFlag, credentialsFileFlag},
} }
} }
@ -332,9 +326,8 @@ func buildCleanupCommand() *cli.Command {
return &cli.Command{ return &cli.Command{
Name: "cleanup", Name: "cleanup",
Action: cliutil.ErrorHandler(cleanupCommand), Action: cliutil.ErrorHandler(cleanupCommand),
Usage: "Cleanup connections for the tunnel with given IDs", Usage: "Cleanup tunnel connections",
ArgsUsage: "TUNNEL-IDS", ArgsUsage: "TUNNEL",
Hidden: hideSubcommands,
} }
} }
@ -362,11 +355,10 @@ func buildRouteCommand() *cli.Command {
Action: cliutil.ErrorHandler(routeCommand), Action: cliutil.ErrorHandler(routeCommand),
Usage: "Define what hostname or load balancer can route to this tunnel", Usage: "Define what hostname or load balancer can route to this tunnel",
Description: `The route defines what hostname or load balancer can route to this tunnel. Description: `The route defines what hostname or load balancer can route to this tunnel.
To route a hostname: cloudflared tunnel route dns <tunnel ID> <hostname>
To route a load balancer: cloudflared tunnel route lb <tunnel ID> <load balancer name> <load balancer pool> To route a hostname: cloudflared tunnel route dns <tunnel ID> <hostname>
If you don't specify a load balancer pool, we will create a new pool called tunnel:<tunnel ID>`, To use this tunnel as a load balancer origin: cloudflared tunnel route lb <tunnel ID> <load balancer name> <load balancer pool>`,
ArgsUsage: "dns|lb TUNNEL-ID HOSTNAME [LB-POOL]", ArgsUsage: "dns|lb TUNNEL HOSTNAME [LB-POOL]",
Hidden: hideSubcommands,
} }
} }