-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
179 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,51 +9,98 @@ with already installed dependencies. | |
|
||
Requires Rust 1.51. | ||
|
||
`cargo install cargo-temp` | ||
``` | ||
cargo install cargo-temp | ||
``` | ||
|
||
## Usage | ||
|
||
Create a new temporary project: | ||
|
||
* With no additional dependencies: | ||
`$ cargo-temp` | ||
|
||
``` | ||
cargo-temp | ||
``` | ||
|
||
* With multiple dependencies: | ||
`$ cargo-temp rand tokio` | ||
|
||
``` | ||
cargo-temp rand tokio | ||
``` | ||
|
||
* When specifying a version: | ||
`$ cargo-temp anyhow=1.0` | ||
* Using the [cargo's comparison requirements][comparison]: | ||
`$ cargo-temp anyhow==1.0.13` | ||
``` | ||
cargo-temp anyhow=1.0` | ||
``` | ||
|
||
Using the [cargo's comparison requirements][comparison]: | ||
|
||
* Exact version: | ||
``` | ||
cargo-temp anyhow==1.0.13 | ||
``` | ||
|
||
* Maximal version: | ||
``` | ||
cargo-temp anyhow=<1.0.2 | ||
``` | ||
|
||
### Repositories | ||
|
||
You can add repositories to your `Cargo.toml`. | ||
|
||
Examples: | ||
|
||
* HTTP | ||
`$ cargo-temp anyhow=https://github.com/dtolnay/anyhow.git` | ||
* HTTP: | ||
``` | ||
cargo-temp anyhow=https://github.com/dtolnay/anyhow.git | ||
``` | ||
|
||
* SSH | ||
`$ cargo-temp anyhow=ssh://[email protected]/dtolnay/anyhow.git` | ||
``` | ||
cargo-temp anyhow=ssh://[email protected]/dtolnay/anyhow.git | ||
``` | ||
|
||
To choose a branch or a revision: | ||
|
||
* Branch | ||
`$ cargo-temp anyhow=https://github.com/dtolnay/anyhow.git#branch=master` | ||
* Branch: | ||
``` | ||
cargo-temp anyhow=https://github.com/dtolnay/anyhow.git#branch=master | ||
``` | ||
|
||
* Revision | ||
`$ cargo-temp anyhow=https://github.com/dtolnay/anyhow.git#rev=7e0f77a38` | ||
* Revision: | ||
``` | ||
cargo-temp anyhow=https://github.com/dtolnay/anyhow.git#rev=7e0f77a38 | ||
``` | ||
|
||
Without a branch or a revision, cargo will use the default branch of the repository. | ||
Without a branch or a revision, cargo will use the default branch of the | ||
repository. | ||
|
||
## Features | ||
|
||
### The TO_DELETE file | ||
|
||
If you change your mind and decide to keep the project you can just delete the | ||
`TO_DELETE` file and the directory will not be deleted when the shell or the | ||
editor exits. | ||
|
||
### Git Working Tree | ||
|
||
You can create a git worktree from the current repository using: | ||
|
||
``` | ||
cargo-temp --worktree | ||
``` | ||
|
||
This will create a new working tree at the current HEAD. | ||
You can specify a branch like this: | ||
|
||
``` | ||
cargo-temp --worktree <branch> | ||
``` | ||
|
||
When exiting the shell (or your editor) the working tree will be cleaned up. | ||
Equivalent to `git worktree prune`. | ||
|
||
## Settings | ||
|
||
The config file is located at `{CONFIG_DIR}/cargo-temp/config.toml`. | ||
|
@@ -66,32 +113,36 @@ and the [Known Folder system][knownfolder] on Windows. | |
The path where the temporary projects are created. | ||
Set on the cache directory by default. | ||
|
||
`temporary_project_dir = "/home/name/.cache/cargo-temp/"` | ||
```toml | ||
temporary_project_dir = "/home/name/.cache/cargo-temp/" | ||
``` | ||
|
||
### Cargo target directory | ||
|
||
Cargo's target directory override. | ||
This setting is unset by default and will be ignored if the `CARGO_TARGET_DIR` | ||
environment variable is already set. | ||
|
||
`temporary_project_dir = "/home/name/repos/tmp"` | ||
```toml | ||
temporary_project_dir = "/home/name/repos/tmp" | ||
``` | ||
|
||
### Editor | ||
|
||
You can use `editor` to start an IDE instead of a shell | ||
and `editor_args` to provide its arguments. These settings are unset by default. | ||
|
||
* Example to run VS Code on Unix | ||
```toml | ||
editor = "/usr/bin/code" | ||
editor_args = [ "--wait", "--new-window" ] | ||
``` | ||
```toml | ||
editor = "/usr/bin/code" | ||
editor_args = [ "--wait", "--new-window" ] | ||
``` | ||
|
||
* Example to run VS Code on Windows | ||
```toml | ||
editor = "C:\\Program Files\\Microsoft VS Code\\Code.exe" | ||
editor_args = [ "--wait", "--new-window" ] | ||
``` | ||
```toml | ||
editor = "C:\\Program Files\\Microsoft VS Code\\Code.exe" | ||
editor_args = [ "--wait", "--new-window" ] | ||
``` | ||
|
||
[comparison]: https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#comparison-requirements | ||
[xdg]: https://docs.rs/xdg/2.2.0/xdg/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters