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

RSDK-9287: standardize command flags #4669

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

purplenicole730
Copy link
Member

@purplenicole730 purplenicole730 commented Jan 2, 2025

Ticket

Changes:

  • make a generic name flag
  • change organization and location flags to be org-id and location-id.

Testing:
NOTE: The name changes were NOT tested since nothing changed other than var name

  • locally ran all commands with changed org-id and location-id args (bonus, learned a lot about how our CLI works!)
rdk % go run ./cli/viam machines list --help              
NAME:
   viam machines list - list machines in an organization and location

USAGE:
   viam machines list [command options] [arguments...]

OPTIONS:
   --location-id value, --location value  (default: first location alphabetically)
   --org-id value, --organization value   (default: first organization alphabetically)

rdk % go run ./cli/viam machines list --org-id <...> --location-id <...>
<...> (id: <...>)

rdk % go run ./cli/viam machines api-key create --org-id <...> --name test --machine-id <...>
Error: Rpc error: code = InvalidArgument desc = mongo: no documents in result

rdk % go run ./cli/viam machines api-key create --machine-id <...> --name "test" --org-id <...>
Info: Successfully created key:
Key ID: <...>
Key Value: <...>
Warning: Keep this key somewhere safe; it has full write access to your machine

rdk % go run ./cli/viam machines status --org-id <...> --location-id <...> --machine <...>
ID: <...>
Name: <...>
Last Access: Fri Jan  3 19:38:07 UTC 2025 (594.392ms ago)
Parts:
        ID: <...>
        Name: <...>-main (main)
        Last Access: Fri Jan  3 19:38:07 UTC 2025 (594.442ms ago)

rdk % go run ./cli/viam machines logs --org-id <...> --location-id <...> --machine <...> --errors --count 2
<...>-main
        2025-01-03T19:23:11.447Z        error  ...
        2025-01-03T19:23:11.447Z        error  ...

rdk % go run ./cli/viam machines part status --org-id <...> --location-id <...> --machine <...> --part <...>
ID: <...>
Name: <...>-main (main)
Last Access: Fri Jan  3 19:45:03 UTC 2025 (389.716ms ago)

rdk % go run ./cli/viam machines part logs --org-id <...> --location-id <...> --machine <...> --part <...> --errors --count 2
2025-01-03T19:23:11.447Z        error   ...
2025-01-03T19:23:11.447Z        error   ...

rdk % go run ./cli/viam machines part restart --org-id <...> --location-id <...> --machine <...> --part <...>
Info: Request to restart part sent successfully

rdk % go run ./cli/viam machines part run --org-id <...> --location-id <...> --machine <...> --part <...> --data '{"name": "motor1"}'  viam.component.motor.v1.MotorService.IsPowered  
{
  "isOn": false,
  "powerPct": 0
}

rdk % go run ./cli/viam machines part shell --org-id <...> --location-id <...> --machine <...> --part <...>                
Info: Ensure machine part has a valid shell type service
Error: Shell service is not enabled on this machine part
exit status 1

rdk % go run ./cli/viam machines part cp --org-id <...> --location-id <...> --machine <...> --part <...> my_file machine:/home/user/
Error: Shell service is not enabled on this machine part
exit status 1

@viambot viambot added the safe to test This pull request is marked safe to test from a trusted zone label Jan 2, 2025
@@ -1462,11 +1457,13 @@ var app = &cli.App{
Usage: "list machines in an organization and location",
Flags: []cli.Flag{
&cli.StringFlag{
Name: organizationFlag,
Name: generalFlagOrgID,
Aliases: []string{generalFlagAliasOrgID},
Copy link
Member Author

@purplenicole730 purplenicole730 Jan 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This now makes a help message look like:

rdk % go run ./cli/viam machines list --help              
NAME:
   viam machines list - list machines in an organization and location

USAGE:
   viam machines list [command options] [arguments...]

OPTIONS:
   --location-id value, --location value  (default: first location alphabetically)
   --org-id value, --organization value   (default: first organization alphabetically)

This applies to all the org and location changes. In the ticket, it says we should stop advertising the wrong flags (aka aliases). I changed the comments to reflect these changes, but wanted to make sure that the help messages were fine.

@purplenicole730 purplenicole730 marked this pull request as ready for review January 3, 2025 20:21
@purplenicole730 purplenicole730 requested a review from a team as a code owner January 3, 2025 20:21
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Jan 3, 2025
Copy link
Member

@njooma njooma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
safe to test This pull request is marked safe to test from a trusted zone
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants