@@ -12,13 +12,14 @@ import (
1212 "github.com/urfave/cli/v2"
1313
1414 "github.com/NodeOps-app/createos-cli/internal/api"
15+ "github.com/NodeOps-app/createos-cli/internal/cmdutil"
1516)
1617
1718func newDeploymentLogsCommand () * cli.Command {
1819 return & cli.Command {
1920 Name : "logs" ,
2021 Usage : "Get logs for a deployment" ,
21- ArgsUsage : "< project-id> <deployment-id>" ,
22+ ArgsUsage : "[ project-id] <deployment-id>" ,
2223 Description : "Fetches the latest logs for a running deployment.\n \n " +
2324 " To find your deployment ID, run:\n " +
2425 " createos deployments list <project-id>" ,
@@ -35,17 +36,15 @@ func newDeploymentLogsCommand() *cli.Command {
3536 },
3637 },
3738 Action : func (c * cli.Context ) error {
38- if c .NArg () < 2 {
39- return fmt .Errorf ("please provide a project ID and deployment ID\n \n Example:\n createos deployments logs <project-id> <deployment-id>" )
40- }
41-
4239 client , ok := c .App .Metadata [api .ClientKey ].(* api.APIClient )
4340 if ! ok {
4441 return fmt .Errorf ("you're not signed in — run 'createos login' to get started" )
4542 }
4643
47- projectID := c .Args ().Get (0 )
48- deploymentID := c .Args ().Get (1 )
44+ projectID , deploymentID , err := cmdutil .ResolveProjectScopedArg (c .Args ().Slice (), "a deployment ID" )
45+ if err != nil {
46+ return err
47+ }
4948
5049 logs , err := client .GetDeploymentLogs (projectID , deploymentID )
5150 if err != nil {
0 commit comments