Stash Commands

Stash Commands

The Camber CLI provides several commands to manage your files in Camber Stash. This page covers the most common stash operations: listing, copying, and removing files.

Listing Files and Directories

Use the camber stash ls command to list files and directories in your stash.

When executing the camber stash ls command without any arguments, it will list all files in the base directory your user stash.

To list files in a subdirectory provide the complete path:

camber stash ls stash://your-username/path

You can also list all the files in the directories of a stash location by setting the recursive flag -r.

camber stash ls -r stash://your-username/path

If you have a large number of files or directories in your stash this may take a moment. Flags: –recursive, -r bool List files and directories recursively (default: false) –all, -a bool Include hidden files and directories (default: false) –output string Output format: json


### Examples

List files in the `demos` subdirectory in your Stash

```bash
camber stash ls stash://your-username/demos

Output:

Name                                     Type                 Size
----                                     ----                 ----
.git                                     directory
10-get-started                           directory
20-tutorials                             directory
30-applications                          directory
.gitignore                               file                 46B
README.md                                file                 118B

Recursively list all files in your stash:

camber stash ls -r stash://your-username/

Show all files (including hidden):

camber stash ls -a stash://your-username/path

JSON output format:

camber stash ls --output json stash://your-username/path

Team stash listing:

First, to see what Team Stash directories are available to you enter camber me. Then you can use the Stash CLI to view files under a path:

camber stash ls stash://team-name/path

You can also get the output in JSON format:

camber me --output json

Removing Files and Directories

To remove files or directories from your stash, use the camber stash rm command:

camber stash rm stash://your-username/path

To delete a directory and any files or directories it contains provide the -r flag.

To bypass the confirmation prompt for this action using the -f flag.

⚠️
When removing a directory, you must use the -r flag. The command will fail if you attempt to remove a directory without the recursive flag.

Examples

Remove a file:

camber stash rm stash://your-username/file.txt

Remove a directory and any files and directories it contains:

camber stash rm -r stash://your-username/demos

Remove a directory without confirmation:

camber stash rm -rf stash://your-username/demos
⚠️
Removing files and directories is permanent and cannot be undone. Use this command with caution.

Copying Files and Directories

The camber stash cp command allows you to download, upload, or copy files between Stash locations.

camber stash cp source-path destination-path
Flags:
      --recursive, -r bool   Copy directories recursively (required for directories)
⚠️
When copying a directory, you must use the -r or --recursive flag. The command will fail if you attempt to copy a directory without the recursive flag.

Common Use Cases

Copying Files

When copying files, you can either:

  • Copy to a directory (preserves original filename)
  • Copy with a specific name

Copy a file to a directory (preserves original filename):

# Local to private stash
camber stash cp ./local-file.txt stash://your-username/documents/

# Stash to local
camber stash cp stash://your-username/documents/file.txt ./downloaded-files/

# Stash to stash
camber stash cp stash://your-username/demos/README.md stash://your-username/backup/

Copy a file with a specific name:

# Local to private stash
camber stash cp ./local-file.txt stash://your-username/documents/renamed-file.txt

# Stash to local
camber stash cp stash://your-username/documents/file.txt ./renamed-file.txt

# Stash to stash
camber stash cp stash://your-username/demos/README.md stash://your-username/backup/README-backup.md

Copying Directories

When copying directories, the contents of the source directory will be copied to the destination path. Always use the -r flag.

# Local to private stash
camber stash cp -r ./local-directory/ stash://your-username/documents/

# Stash to local
camber stash cp -r stash://your-username/documents/ ./downloaded-docs/

# Stash to stash
camber stash cp -r stash://your-username/demos/10-get-started/ stash://your-username/archive/10-get-started/

Team and Public Stash Operations

In addition to your private stash, you can also access:

  • Team stash: If you are a member of a team, you can access the team’s stash (stash://team-name/)
  • Public stash: Everyone has read-only access to the Camber public stash (stash://public/)
⚠️
The public stash (stash://public/) is read-only. You can copy from public stash to your private or team stash, but you cannot copy to public stash.

Examples:

# Copy to/from team stash
camber stash cp ./local-file.txt stash://team-name/shared-docs/
camber stash cp stash://team-name/shared-docs/file.txt ./downloaded-files/

# Copy from public stash
camber stash cp stash://public/examples/template.md stash://your-username/projects/

Error Handling

Common errors and their solutions:

  1. Permission Denied: Ensure you have the necessary permissions to access the source and destination paths.
  2. Directory Copy Without -r: Always use the -r flag when copying directories.
  3. Path Not Found: Verify that the source path exists and is correctly specified.

Testing Path Existence

The camber stash test command allows you to check if a path exists and what type it is:

camber stash test stash://your-username/path
Flags:
      --exists, -e bool      Check if the path exists (default: false)
      --file, -f bool        Check if the path is a file (default: false)
      --directory, -d bool   Check if the path is a directory (default: false)
      --output string        Output format: json

Examples

Check if a path exists:

camber stash test -e stash://your-username/file.txt

Check if a path is a file:

camber stash test -f stash://your-username/file.txt

Check if a path is a directory:

camber stash test -d stash://your-username/directory

Get output in JSON format:

camber stash test -e --output json stash://your-username/file.txt

Creating Directories

The camber stash mkdir command creates new directories in your stash:

camber stash mkdir stash://your-username/new-directory
Flags:
      --output string        Output format: json

Examples

Create a new directory:

camber stash mkdir stash://your-username/projects/new-project

Create a directory in a team stash:

camber stash mkdir stash://team-name/shared-projects/new-project

Create a directory with JSON output:

camber stash mkdir --output json stash://your-username/projects/new-project