CLI Usage
The CLI for switchvsversion is designed to be intuitive and flexible, allowing users to compare versions and identify differences across various sources.
General Usage
switchvsversion [OPTIONS] [TARGET...]
Where:
[OPTIONS]
: Optional flags and arguments that modify the behavior of the tool.[TARGET...]
: The paths to the files or directories you want to compare.
Options
-h, --help
: Display this help message and exit.
-v, --version
: Print the version number and exit.
-s, --source [SOURCE]
: Specifies the source type for the comparison. Default: git
.
* Available source types: git
, local
(for local files/directories).
-d, --destination [DESTINATION]
: Specifies the destination type for the comparison. Default: local
.
* Available destination types: git
, local
.
-b, --branch [BRANCH]
: Specifies the branch to use for the comparison. Default: main
.
* Only used when comparing with a Git source (git
).
* If not specified, the current branch is used.
-p, --path [PATH]
: The relative path to the file or directory within the target.
* Used when comparing with a local source (local
).
* If not specified, the entire directory is used.
-c, --commit [COMMIT]
: The commit hash or tag to use for the comparison.
* Only used when comparing with a Git source (git
).
* If not specified, the current commit is used.
-o, --output [OUTPUT]
: Specifies the output format for the comparison.
* Available output formats: diff
, json
.
* Default: diff
.
-f, --format [FORMAT]
: Specifies the output format for the diff.
* Available formats: unified
, side-by-side
.
* Default: unified
.
Examples
1. Comparing local files against a Git branch:
switchvsversion -s local -d git -b main -p my_file.txt /path/to/local/directory https://github.com/my-user/my-repo
This compares the file my_file.txt
located at /path/to/local/directory
against the main
branch of the my-repo
repository on GitHub.
2. Comparing two Git branches:
switchvsversion -s git -d git -b main -c my_branch https://github.com/my-user/my-repo https://github.com/my-user/my-repo
This compares the main
branch against the my_branch
branch of the my-repo
repository on GitHub.
3. Generating JSON output:
switchvsversion -o json -s local -d git -b main /path/to/local/directory https://github.com/my-user/my-repo
This generates a JSON output of the comparison between the local directory and the main
branch of the my-repo
repository on GitHub.
4. Using the default options:
switchvsversion /path/to/local/directory https://github.com/my-user/my-repo
This compares the main
branch of the my-repo
repository on GitHub against the local
directory using diff
as the output format.
5. Using the local
source:
switchvsversion -s local -d local -p my_file.txt /path/to/local/directory /path/to/another/local/directory
This compares the my_file.txt
file in the local
directory /path/to/local/directory
against the same file in the local
directory /path/to/another/local/directory
.
Important Notes:
- The source and destination types must be compatible.
- If comparing against a Git source, the branch or commit to use must be specified.
- The
-p
option is only used when comparing against a local source. - The
-o
option can be used to specify the desired output format.
For more details, consult the source code of the switchvsversion
CLI tool.