mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-26 11:03:34 +00:00
feat: add 'uc caddy logs' alias for 'uc logs caddy' (#381)
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package caddy
|
||||
|
||||
import (
|
||||
"github.com/psviderski/uncloud/cmd/uncloud/service"
|
||||
"github.com/psviderski/uncloud/internal/cli"
|
||||
"github.com/psviderski/uncloud/internal/cli/logs"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func NewLogsCommand() *cobra.Command {
|
||||
var options logs.Options
|
||||
|
||||
cmd := &cobra.Command{
|
||||
Use: "logs",
|
||||
Aliases: []string{"log"},
|
||||
Short: "View caddy logs.",
|
||||
Long: `View caddy logs.
|
||||
|
||||
This calls "uc logs caddy", see "uc logs" for the documention.
|
||||
`,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
args = append([]string{"caddy"}, args...)
|
||||
uncli := cmd.Context().Value("cli").(*cli.CLI)
|
||||
return service.RunLogs(cmd.Context(), uncli, args, options)
|
||||
},
|
||||
}
|
||||
cmd.Flags().AddFlagSet(logs.Flags(&options))
|
||||
return cmd
|
||||
}
|
||||
@@ -12,6 +12,7 @@ func NewRootCommand() *cobra.Command {
|
||||
cmd.AddCommand(
|
||||
NewConfigCommand(),
|
||||
NewDeployCommand(),
|
||||
NewLogsCommand(),
|
||||
)
|
||||
return cmd
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ If no services are specified, streams logs from all services defined in the Comp
|
||||
uc logs -m machine1,machine2 web api`,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
uncli := cmd.Context().Value("cli").(*cli.CLI)
|
||||
return runLogs(cmd.Context(), uncli, args, options)
|
||||
return RunLogs(cmd.Context(), uncli, args, options)
|
||||
},
|
||||
GroupID: groupID,
|
||||
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]cobra.Completion, cobra.ShellCompDirective) {
|
||||
@@ -77,7 +77,7 @@ If no services are specified, streams logs from all services defined in the Comp
|
||||
return cmd
|
||||
}
|
||||
|
||||
func runLogs(ctx context.Context, uncli *cli.CLI, args []string, opts logs.Options) error {
|
||||
func RunLogs(ctx context.Context, uncli *cli.CLI, args []string, opts logs.Options) error {
|
||||
serviceArgs, err := logs.ParseServiceArgs(args)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user