(t *testing.T)
| 390 | } |
| 391 | |
| 392 | func TestAdaptShellArgs(t *testing.T) { |
| 393 | rootCmd := &cobra.Command{Use: "pikpakcli"} |
| 394 | |
| 395 | listCmd := &cobra.Command{Use: "ls"} |
| 396 | listCmd.Flags().StringP("path", "p", "/", "") |
| 397 | rootCmd.AddCommand(listCmd) |
| 398 | |
| 399 | emptyCmd := &cobra.Command{Use: "empty"} |
| 400 | emptyCmd.Flags().StringP("path", "p", "/", "") |
| 401 | rootCmd.AddCommand(emptyCmd) |
| 402 | |
| 403 | downloadCmd := &cobra.Command{Use: "download"} |
| 404 | downloadCmd.Flags().StringP("path", "p", "/", "") |
| 405 | downloadCmd.Flags().StringP("parent-id", "P", "", "") |
| 406 | rootCmd.AddCommand(downloadCmd) |
| 407 | |
| 408 | shareCmd := &cobra.Command{Use: "share"} |
| 409 | shareCmd.Flags().StringP("path", "p", "/", "") |
| 410 | shareCmd.Flags().StringP("parent-id", "P", "", "") |
| 411 | rootCmd.AddCommand(shareCmd) |
| 412 | |
| 413 | uploadCmd := &cobra.Command{Use: "upload"} |
| 414 | uploadCmd.Flags().StringP("path", "p", "/", "") |
| 415 | uploadCmd.Flags().StringP("parent-id", "P", "", "") |
| 416 | rootCmd.AddCommand(uploadCmd) |
| 417 | |
| 418 | deleteCmd := &cobra.Command{Use: "delete"} |
| 419 | deleteCmd.Aliases = []string{"del", "rm"} |
| 420 | deleteCmd.Flags().StringP("path", "p", "/", "") |
| 421 | rootCmd.AddCommand(deleteCmd) |
| 422 | |
| 423 | renameCmd := &cobra.Command{Use: "rename"} |
| 424 | rootCmd.AddCommand(renameCmd) |
| 425 | |
| 426 | newCmd := &cobra.Command{Use: "new"} |
| 427 | newCmd.Aliases = []string{"n"} |
| 428 | newFolderCmd := &cobra.Command{Use: "folder"} |
| 429 | newFolderCmd.Flags().StringP("path", "p", "/", "") |
| 430 | newFolderCmd.Flags().StringP("parent-id", "P", "", "") |
| 431 | newCmd.AddCommand(newFolderCmd) |
| 432 | newURLCmd := &cobra.Command{Use: "url"} |
| 433 | newURLCmd.Flags().StringP("path", "p", "/", "") |
| 434 | newURLCmd.Flags().StringP("parent-id", "P", "", "") |
| 435 | newCmd.AddCommand(newURLCmd) |
| 436 | newSHACmd := &cobra.Command{Use: "sha"} |
| 437 | newSHACmd.Flags().StringP("path", "p", "/", "") |
| 438 | newSHACmd.Flags().StringP("parent-id", "P", "", "") |
| 439 | newCmd.AddCommand(newSHACmd) |
| 440 | rootCmd.AddCommand(newCmd) |
| 441 | |
| 442 | tests := []struct { |
| 443 | name string |
| 444 | args []string |
| 445 | want []string |
| 446 | }{ |
| 447 | {name: "ls injects current path", args: []string{"ls"}, want: []string{"ls", "-p", "/Movies"}}, |
| 448 | {name: "ls rewrites relative arg", args: []string{"ls", "Kids"}, want: []string{"ls", "/Movies/Kids"}}, |
| 449 | {name: "empty rewrites relative arg", args: []string{"empty", "Kids"}, want: []string{"empty", "/Movies/Kids"}}, |
nothing calls this directly
no test coverage detected