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

Conversation

purplenicole730
Copy link
Member

@purplenicole730 purplenicole730 commented Jan 2, 2025

Ticket

Changes:

  • make a generic name flag
  • add aliases to organization, location, machine, and part flags
  • specify flag id or name depending on usage

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

  • locally ran all commands with a combination of aliases
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 value, --location-id value, --location-name value         (default: first location alphabetically)
   --organization value, --org value, --org-id value, --org-name value  (default: first organization alphabetically)

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

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

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

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

rdk % go run ./cli/viam machines api-key create --machine <...> --name "test" --org <...>
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 <...>
ID: <...>
Name: <...>
Last Access: Mon Jan  6 16:13:51 UTC 2025 (855.467ms ago)
Parts:
        ID: <...>
        Name: <...>-main (main)
        Last Access: Mon Jan  6 16:13:51 UTC 2025 (855.467ms ago)

rdk % go run ./cli/viam machines status --organization  <...> --location-name <...> --machine <...>
ID: <...>
Name: <...>
Last Access: Mon Jan  6 16:27:41 UTC 2025 (1h43m4.073189s ago)
Parts:
        ID: <...>
        Name: <...>-main (main)
        Last Access: Mon Jan  6 16:27:41 UTC 2025 (1h43m4.073248s ago)

rdk % go run ./cli/viam machines status --organization  <...> --location <...> --machine-name <...>
ID: <...>
Name: <...>
Last Access: Mon Jan  6 16:27:41 UTC 2025 (1h43m4.073189s ago)
Parts:
        ID: <...>
        Name: <...>-main (main)
        Last Access: Mon Jan  6 16:27:41 UTC 2025 (1h43m4.073248s ago)

rdk % go run ./cli/viam machines logs --org <...> --location <...> --machine <...> --errors --count 2
<...>-main
        No recent logs

rdk % go run ./cli/viam machines part status --org <...> --location <...> --machine <...> --part <...>
ID: <...>
Name: <...>-main (main)
Last Access: Mon Jan  6 16:20:59 UTC 2025 (342.901ms ago)

rdk % go run ./cli/viam machines part status --org-id <...> --location-id <...> --machine-id <...> --part-id <...>
ID: <...>
Name: <...>-main (main)
Last Access: Mon Jan  6 16:27:41 UTC 2025 (1h44m52.376819s ago)

rdk % go run ./cli/viam machines part status --organization <...> --location-name <...> --machine-name <...> --part-name <...>
ID: <...>
Name: <...>-main (main)
Last Access: Mon Jan  6 16:27:41 UTC 2025 (1h46m3.162506s ago)

rdk % go run ./cli/viam machines part logs --org <...> --location <...> --machine <...> --part <...> --errors --count 2
No recent logs

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

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

rdk % go run ./cli/viam machines part shell --org-id <...> --location-name <...> --machine-id <...> --part-id <...>                
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 --organization <...> --location-name <...> --machine <...> --part-name <...> 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
cli/app.go Outdated Show resolved Hide resolved
@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

@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 6, 2025
@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 6, 2025
@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 6, 2025
@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 6, 2025
@viambot viambot removed the safe to test This pull request is marked safe to test from a trusted zone label Jan 6, 2025
@viambot viambot added the safe to test This pull request is marked safe to test from a trusted zone label Jan 6, 2025
@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 6, 2025
@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 6, 2025
@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 6, 2025
@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 6, 2025
@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 6, 2025
@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 6, 2025
Copy link
Member

@stuqdog stuqdog left a comment

Choose a reason for hiding this comment

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

lgtm!

@purplenicole730 purplenicole730 merged commit 35c9ead into viamrobotics:main Jan 6, 2025
16 checks passed
@purplenicole730 purplenicole730 deleted the RSDK-9287-standardize-command-flags branch January 6, 2025 19:37
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.

4 participants