Skip to content

File and folder management in the CLI#8

Merged
berggren merged 1 commit intomainfrom
folder-commands
Mar 20, 2026
Merged

File and folder management in the CLI#8
berggren merged 1 commit intomainfrom
folder-commands

Conversation

@berggren
Copy link
Copy Markdown
Contributor

Summary

Added file and folder management subcommands to the CLI, implemented chunked uploads with progress tracking, and refactored internal folder service methods for naming consistency.

Manage files

Usage:
  openrelik files [command]

Available Commands:
  download    Download a file
  info        Get file metadata
  list        List files in a folder
  upload      Upload a file
Manage folders

Usage:
  openrelik folders [command]

Available Commands:
  create      Create a folder
  list        List folders

Technical Details:

  • CLI Command Expansion: Integrated files and folders subcommands into the root command in cmd/openrelik/internal/cli/cli.go. Added SilenceErrors: true to the root configuration to manage error output through the command's return values.
  • File Operations: Implemented list, info, download, and upload functionality in files.go. The upload implementation supports chunked transfers (default 4MB) and progress reporting, while the download logic includes an interactive overwrite confirmation and directory-aware path resolution.
  • Folder Operations: Added list and create subcommands in folders.go. These support both root-level operations and subfolder management via parent ID flags.
  • Progress Tracking Utility: Introduced a ProgressTracker and ProgressReader in internal/util/util.go. This provides real-time CLI feedback including a progress bar, transfer speed, ETA calculation, and retry counts for I/O operations.
  • API Client Refactoring: Renamed several methods in FoldersService to better align with standard naming conventions:
    • GetRootFolders to ListRootFolders
    • GetSubFolders to ListSubFolders
    • GetFiles to ListFiles
  • Data Formatting Improvements: Updated FprintStruct in the utility package to support slices and pointers, allowing the CLI to print multiple records separated by delimiters.
  • Testing: Added mock-server based unit tests in files_test.go and folders_test.go covering command execution, API interaction, and file system side effects.

@berggren berggren requested a review from hacktobeer March 18, 2026 22:07
@berggren berggren merged commit f9ac84b into main Mar 20, 2026
3 checks passed
@berggren berggren deleted the folder-commands branch March 20, 2026 07:57
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.

2 participants