-
Notifications
You must be signed in to change notification settings - Fork 111
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-9288: declutter UI #4692
Merged
purplenicole730
merged 41 commits into
viamrobotics:main
from
purplenicole730:RSDK-9288-declutter-UI
Jan 16, 2025
Merged
RSDK-9288: declutter UI #4692
Changes from all commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
00516e9
hide help commands from subcommands
purplenicole730 fd7dd48
declutter login usagetext
purplenicole730 6b6e744
remove duplicate command
purplenicole730 0f2aaf4
standardize and fix usage text for organizations subcommand
purplenicole730 c8ce068
fix list locations command
purplenicole730 d023c01
fix usage text for viam command
purplenicole730 ef67b88
make lint
purplenicole730 d500403
allow only unrequired options in usage text
purplenicole730 9598d54
add subcommand support to createusagetext
purplenicole730 74d6e32
locations usage text
purplenicole730 217141d
make lint
purplenicole730 1260c94
add usagetext for profiles commands with required flags
purplenicole730 1e71c16
fix/standardize usagetext for data commands
purplenicole730 ac45897
add usagetext to dataset commands, remove unnecessary code
purplenicole730 2eb8d38
standardize train subcommands
purplenicole730 f383515
standardize machine subcommands
purplenicole730 51ac5e1
standardize module subcommands
purplenicole730 575e412
standardize package subcommands
purplenicole730 1d3ad89
standardize training script subcommands
purplenicole730 035c9da
standardize rest of commands
purplenicole730 7b59c42
make lint
purplenicole730 16a7a8f
Merge branch 'main' into RSDK-9288-declutter-UI
purplenicole730 c65cfc4
fix new command
purplenicole730 a488acc
fix new commands
purplenicole730 2099e42
make lint
purplenicole730 ffb80c1
nit
purplenicole730 0a7f540
nits
purplenicole730 2754e3e
deal with other argument-using commands
purplenicole730 4e621bb
consolidate flags
purplenicole730 05065fc
remove unnecessary flag
purplenicole730 3d95348
basic cleanup
purplenicole730 934b226
generalize format accepted values
purplenicole730 3a59aa2
add pr feedback
purplenicole730 f6d7c0e
Merge branch 'main' into RSDK-9288-declutter-UI
purplenicole730 4cec57f
erase comment
purplenicole730 ad6d741
make lint
purplenicole730 15e04b7
make lint
purplenicole730 4fe3249
make machinespartcp a function on viamclient
purplenicole730 74682e7
update tests
purplenicole730 fdfefa9
Merge branch 'main' into RSDK-9288-declutter-UI
purplenicole730 16528ca
merge fixes
purplenicole730 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -601,15 +601,16 @@ func (c *viamClient) listOAuthAppsAction(cCtx *cli.Context, orgID string) error | |
return nil | ||
} | ||
|
||
type listLocationsArgs struct { | ||
Organization string | ||
} | ||
|
||
// ListLocationsAction is the corresponding Action for 'locations list'. | ||
func ListLocationsAction(c *cli.Context, args emptyArgs) error { | ||
func ListLocationsAction(c *cli.Context, args listLocationsArgs) error { | ||
client, err := newViamClient(c) | ||
if err != nil { | ||
return err | ||
} | ||
// TODO(RSDK-9288) - this is brittle and inconsistent with how most data is passed. | ||
// Move this to being a flag (but make sure existing workflows still work!) | ||
orgStr := c.Args().First() | ||
listLocations := func(orgID string) error { | ||
locs, err := client.listLocations(orgID) | ||
if err != nil { | ||
|
@@ -620,6 +621,10 @@ func ListLocationsAction(c *cli.Context, args emptyArgs) error { | |
} | ||
return nil | ||
} | ||
orgStr := args.Organization | ||
if orgStr == "" { | ||
orgStr = c.Args().First() | ||
} | ||
if orgStr == "" { | ||
orgs, err := client.listOrganizations() | ||
if err != nil { | ||
|
@@ -754,14 +759,14 @@ func RobotsStatusAction(c *cli.Context, args robotsStatusArgs) error { | |
|
||
func getNumLogs(c *cli.Context, numLogs int) (int, error) { | ||
if numLogs < 0 { | ||
warningf(c.App.ErrWriter, "Provided negative %q value. Defaulting to %d", logsFlagCount, defaultNumLogs) | ||
warningf(c.App.ErrWriter, "Provided negative %q value. Defaulting to %d", generalFlagCount, defaultNumLogs) | ||
return defaultNumLogs, nil | ||
} | ||
if numLogs == 0 { | ||
return defaultNumLogs, nil | ||
} | ||
if numLogs > maxNumLogs { | ||
return 0, errors.Errorf("provided too high of a %q value. Maximum is %d", logsFlagCount, maxNumLogs) | ||
return 0, errors.Errorf("provided too high of a %q value. Maximum is %d", generalFlagCount, maxNumLogs) | ||
} | ||
return numLogs, nil | ||
} | ||
|
@@ -1127,20 +1132,22 @@ func (c *viamClient) robotPartRestart(cCtx *cli.Context, args robotsPartRestartA | |
return nil | ||
} | ||
|
||
type robotsPartRunArgs struct { | ||
type machinesPartRunArgs struct { | ||
Organization string | ||
Location string | ||
Machine string | ||
Part string | ||
Data string | ||
Stream time.Duration | ||
Method string | ||
} | ||
|
||
// RobotsPartRunAction is the corresponding Action for 'machines part run'. | ||
func RobotsPartRunAction(c *cli.Context, args robotsPartRunArgs) error { | ||
// TODO(RSDK-9288) - this is brittle and inconsistent with how most data is passed. | ||
// Move this to being a flag (but make sure existing workflows still work!) | ||
svcMethod := c.Args().First() | ||
// MachinesPartRunAction is the corresponding Action for 'machines part run'. | ||
func MachinesPartRunAction(c *cli.Context, args machinesPartRunArgs) error { | ||
svcMethod := args.Method | ||
if svcMethod == "" { | ||
svcMethod = c.Args().First() | ||
} | ||
if svcMethod == "" { | ||
return errors.New("service method required") | ||
} | ||
|
@@ -1250,18 +1257,15 @@ func MachinesPartCopyFilesAction(c *cli.Context, args machinesPartCopyFilesArgs) | |
logger = logging.NewDebugLogger("cli") | ||
} | ||
|
||
return machinesPartCopyFilesAction(c, client, args, logger) | ||
return client.machinesPartCopyFilesAction(c, args, logger) | ||
} | ||
|
||
func machinesPartCopyFilesAction( | ||
c *cli.Context, | ||
client *viamClient, | ||
func (c *viamClient) machinesPartCopyFilesAction( | ||
ctx *cli.Context, | ||
flagArgs machinesPartCopyFilesArgs, | ||
logger logging.Logger, | ||
) error { | ||
// TODO(RSDK-9288) - this is brittle and inconsistent with how most data is passed. | ||
// Move this to being a flag (but make sure existing workflows still work!) | ||
Comment on lines
-1262
to
-1263
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Decided to keep this specific function as is, as it mirrors a well-known behavior with the |
||
args := c.Args().Slice() | ||
args := ctx.Args().Slice() | ||
if len(args) == 0 { | ||
return errNoFiles | ||
} | ||
|
@@ -1307,14 +1311,14 @@ func machinesPartCopyFilesAction( | |
return err | ||
} | ||
|
||
globalArgs, err := getGlobalArgs(c) | ||
globalArgs, err := getGlobalArgs(ctx) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
doCopy := func() error { | ||
if isFrom { | ||
return client.copyFilesFromMachine( | ||
return c.copyFilesFromMachine( | ||
flagArgs.Organization, | ||
flagArgs.Location, | ||
flagArgs.Machine, | ||
|
@@ -1328,7 +1332,7 @@ func machinesPartCopyFilesAction( | |
) | ||
} | ||
|
||
return client.copyFilesToMachine( | ||
return c.copyFilesToMachine( | ||
flagArgs.Organization, | ||
flagArgs.Location, | ||
flagArgs.Machine, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(flyby request) I know you didn't make this change but the definition of
machinesPartCopyFilesAction
here takes a*viamClient
as an argument. Would you mind, as a quick flyby, making it a method on aviamClient
instead of taking theviamClient
as an argument? This would put the syntax more in line with how analogous functions elsewhere in the CLI are structured.