Skip to content

feat(drive): add tree command#72

Merged
rianjs merged 1 commit intomainfrom
feat/66-drive-tree
Jan 25, 2026
Merged

feat(drive): add tree command#72
rianjs merged 1 commit intomainfrom
feat/66-drive-tree

Conversation

@rianjs
Copy link
Copy Markdown
Contributor

@rianjs rianjs commented Jan 25, 2026

Summary

  • Add gro drive tree command to display folder structure
  • Show tree from root or specific folder
  • Support --depth flag to limit traversal depth (default 2)
  • Support --files flag to include files, not just folders
  • Support --json flag for JSON output
  • Tree characters (├── └── │) for visual hierarchy
  • Sort folders before files, then alphabetically

Test Plan

  • gro drive tree --help shows correct usage
  • Tests for command flags and argument validation
  • Tests for printTree() with various tree structures
  • Tests for nested and deeply nested trees
  • Tests for empty folders
  • make verify passes

Closes #66

Add `gro drive tree` command to display folder structure:
- Show tree from root or specific folder
- Support --depth flag to limit traversal depth (default 2)
- Support --files flag to include files, not just folders
- Support --json flag for JSON output
- Tree characters (├── └── │) for visual hierarchy
- Sort folders before files, alphabetically

Closes #66
@rianjs
Copy link
Copy Markdown
Contributor Author

rianjs commented Jan 25, 2026

Test Coverage Assessment for PR #72

Summary

The test coverage for the new tree command is adequate and consistent with the testing patterns established in this codebase.

What is covered

  • Command structure: Flags (--depth, --files, --json), argument validation (0 or 1 args), and descriptions
  • printTree() function: Thoroughly tested with 5 scenarios including single node, children, nested trees, deeply nested trees, and empty children
  • TreeNode struct: JSON serialization and nil children handling

What is not covered

The buildTree() function (the core recursive logic) is not tested. This includes:

  • Folder vs file sorting (folders first, then alphabetically)
  • Depth limiting behavior
  • Error handling when API calls fail
  • Query construction for the --files flag

Assessment

This is acceptable given the established testing patterns in this codebase. Looking at the sibling commands (list, get, download, search), they all follow the same approach:

  • Test command structure and flags
  • Test pure helper functions (buildListQuery, getMimeTypeFilter, formatSize, determineOutputPath, printFileDetails)
  • Do not test the run* functions or mock the API client

The codebase has infrastructure for mocking via ClientFactory, but it's not currently used in any drive command tests. Adding mock-based tests for buildTree() would be nice but is not required to maintain consistency.

Verdict

Tests are sufficient - the PR follows the established testing conventions. The critical output formatting logic (printTree()) is well-tested, and the command structure is validated. Future work could add integration tests or mock-based unit tests for buildTree(), but this is not a blocker.

@rianjs rianjs merged commit fa5d8eb into main Jan 25, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(drive): add tree command

1 participant