mirror of
https://github.com/siderolabs/talos.git
synced 2025-08-10 08:37:03 +02:00
fix: align list and diskusage command flags with their Linux analogs
Fixes: https://github.com/talos-systems/talos/issues/3018 Signed-off-by: Artem Chernyshev <artem.chernyshev@talos-systems.com>
This commit is contained in:
parent
d29e9202f3
commit
a50747a64a
@ -41,7 +41,7 @@ var duCmd = &cobra.Command{
|
||||
}
|
||||
|
||||
stream, err := c.DiskUsage(ctx, &machineapi.DiskUsageRequest{
|
||||
RecursionDepth: recursionDepth,
|
||||
RecursionDepth: recursionDepth + 1,
|
||||
All: all,
|
||||
Threshold: threshold,
|
||||
Paths: paths,
|
||||
|
@ -46,6 +46,10 @@ var lsCmd = &cobra.Command{
|
||||
return completePathFromNode(toComplete), cobra.ShellCompDirectiveNoFileComp
|
||||
},
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
if recurse && recursionDepth != 1 {
|
||||
return fmt.Errorf("only one of flags --recurse and --depth can be specified at the same time")
|
||||
}
|
||||
|
||||
return WithClient(func(ctx context.Context, c *client.Client) error {
|
||||
rootDir := "/"
|
||||
|
||||
@ -71,9 +75,13 @@ var lsCmd = &cobra.Command{
|
||||
}
|
||||
}
|
||||
|
||||
if recurse {
|
||||
recursionDepth = -1
|
||||
}
|
||||
|
||||
stream, err := c.LS(ctx, &machineapi.ListRequest{
|
||||
Root: rootDir,
|
||||
Recurse: recurse,
|
||||
Recurse: recursionDepth > 1 || recurse,
|
||||
RecursionDepth: recursionDepth,
|
||||
Types: reqTypes,
|
||||
})
|
||||
@ -211,7 +219,7 @@ func init() {
|
||||
lsCmd.Flags().BoolVarP(&long, "long", "l", false, "display additional file details")
|
||||
lsCmd.Flags().BoolVarP(&recurse, "recurse", "r", false, "recurse into subdirectories")
|
||||
lsCmd.Flags().BoolVarP(&humanizeFlag, "humanize", "H", false, "humanize size and time in the output")
|
||||
lsCmd.Flags().Int32VarP(&recursionDepth, "depth", "d", 0, "maximum recursion depth")
|
||||
lsCmd.Flags().Int32VarP(&recursionDepth, "depth", "d", 1, "maximum recursion depth")
|
||||
lsCmd.Flags().StringSliceVarP(&types, "type", "t", nil, typesHelp)
|
||||
addCommand(lsCmd)
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ func (suite *DiskUsageSuite) TestSuccess() {
|
||||
}))
|
||||
|
||||
// check total calculation
|
||||
suite.RunCLI([]string{"usage", "--nodes", node, folder, "-d2", "--all"},
|
||||
suite.RunCLI([]string{"usage", "--nodes", node, folder, "-d1", "--all"},
|
||||
base.StdoutMatchFunc(func(stdout string) error {
|
||||
lines := strings.Split(strings.TrimSpace(stdout), "\n")
|
||||
if len(lines) == 1 {
|
||||
|
@ -87,25 +87,14 @@ func (suite *ListSuite) TestDepth() {
|
||||
{separators: 0},
|
||||
|
||||
{separators: 0, flags: []string{"--recurse=false"}},
|
||||
{separators: 5, flags: []string{"--recurse=true"}},
|
||||
|
||||
{separators: 0, flags: []string{"--depth=-1"}},
|
||||
{separators: 0, flags: []string{"--depth=0"}},
|
||||
{separators: 0, flags: []string{"--depth=1"}},
|
||||
{separators: 0, flags: []string{"--depth=2"}},
|
||||
{separators: 0, flags: []string{"--depth=3"}},
|
||||
{separators: 1, flags: []string{"--depth=2"}},
|
||||
{separators: 2, flags: []string{"--depth=3"}},
|
||||
|
||||
{separators: 0, flags: []string{"--recurse=false", "--depth=-1"}},
|
||||
{separators: 0, flags: []string{"--recurse=false", "--depth=0"}},
|
||||
{separators: 0, flags: []string{"--recurse=false", "--depth=1"}},
|
||||
{separators: 0, flags: []string{"--recurse=false", "--depth=2"}},
|
||||
{separators: 0, flags: []string{"--recurse=false", "--depth=3"}},
|
||||
|
||||
{separators: 5, flags: []string{"--recurse=true", "--depth=-1"}},
|
||||
{separators: 5, flags: []string{"--recurse=true", "--depth=0"}},
|
||||
{separators: 0, flags: []string{"--recurse=true", "--depth=1"}},
|
||||
{separators: 1, flags: []string{"--recurse=true", "--depth=2"}},
|
||||
{separators: 2, flags: []string{"--recurse=true", "--depth=3"}},
|
||||
{separators: 5, flags: []string{"--recurse=true"}},
|
||||
} {
|
||||
test := test
|
||||
suite.Run(strings.Join(test.flags, ","), func() {
|
||||
|
@ -1470,7 +1470,7 @@ talosctl list [path] [flags]
|
||||
### Options
|
||||
|
||||
```
|
||||
-d, --depth int32 maximum recursion depth
|
||||
-d, --depth int32 maximum recursion depth (default 1)
|
||||
-h, --help help for list
|
||||
-H, --humanize humanize size and time in the output
|
||||
-l, --long display additional file details
|
||||
|
Loading…
Reference in New Issue
Block a user