A CLI tool that allow you to create a temporary new rust project using cargo with already installed dependencies

Overview

cargo-temp

A CLI tool that allow you to create a new rust project in a temporary directory with already installed dependencies.

Cargo-temp demo

Install

Requires Rust 1.51.

cargo install cargo-temp

Usage

Create a new temporary project:

  • With no additional dependencies: $ cargo-temp

  • With multiple dependencies: $ cargo-temp rand tokio

  • With a dependency that have a fixed version: $ cargo-temp anyhow==1.0.13

Features

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 exits.

Settings

The config file is located at {CONFIG_DIR}/cargo-temp/config.toml. When you run cargo-temp for the first time it will be created automatically

  • temporary_project_dir: path where the temporary projects are created (cache directory by default).
  • cargo_target_dir: cargo's target directory override (unset by default). This setting is ignored if CARGO_TARGET_DIR is already set.
Comments
  • Request: a subcommand to clean the temp projects

    Request: a subcommand to clean the temp projects

    Current state

    I cannot find a way to safely clean the project directory.

    Feature request

    A flag to remove projects that are safe to remove like the ones with TO_DELETE file.

    Perhaps a second --force like flag that removes all projects, no matter whether they have the TO_DELETE file or not.

    opened by amanjeev 10
  • Added Windows support

    Added Windows support

    PS C:\Users\yoh\source\cargo-temp> cargo run
       Compiling cargo-temp v0.1.1 (C:\Users\yoh\source\cargo-temp)
        Finished dev [unoptimized + debuginfo] target(s) in 1.35s
         Running `target\debug\cargo-temp.exe`
         Created binary (application) package
    Microsoft Windows [Version 10.0.21354.1]
    (c) Microsoft Corporation. All rights reserved.
    
    C:\Users\yoh\AppData\Local\cargo-temp\tmp-5nQsQO>dir
     Volume in drive C has no label.
     Volume Serial Number is 48B4-60B2
    
     Directory of C:\Users\yoh\AppData\Local\cargo-temp\tmp-5nQsQO
    
    05/04/2021  04:14 PM    <DIR>          .
    05/04/2021  04:14 PM    <DIR>          ..
    05/04/2021  04:14 PM                 8 .gitignore
    05/04/2021  04:14 PM               233 Cargo.toml
    05/04/2021  04:14 PM    <DIR>          src
    05/04/2021  04:14 PM                53 TO_DELETE
                   3 File(s)            294 bytes
                   3 Dir(s)  361,829,834,752 bytes free
    
    C:\Users\yoh\AppData\Local\cargo-temp\tmp-5nQsQO>exit
    PS C:\Users\yoh\source\cargo-temp>
    
    opened by YohDeadfall 10
  • Request: append name of the project to the directory name

    Request: append name of the project to the directory name

    Thank you for this amazing project that helps me a lot. I will try to attempt this myself as a feature PR but creating this issue here just for the sake of documentation (also in case I missed something).

    Current state

    Right now I can generate a new temp crate with a specific name by passing --name flag like

    $ cargo temp --name mytrialproj
    

    It generates a directory in the cargo temp directory correctly with name like tmp-EUsdfsl.

    Feature request

    If name is specified with --name flag, append that to the directory name of the newly generated project. e.g. tmp-EUsdfsl-mytrialproj.

    opened by amanjeev 9
  • Bindings

    Bindings

    I have an error when i try to publish a new version of cargo-temp, cargo-release said that i need to have a version for bidings to be able to publish. So i have move bindings as a workspace member

    opened by yozhgoor 7
  • Replace == with = in documentation

    Replace == with = in documentation

    I found the documentation confusing because the extra =. anyhow = "=1.1.0" does seem to be valid in Cargo.toml but I don't think it is ever used because I don't see how it is different to anyhow = "1.1.0".

    I replaced the test with one using ^ as I've seen that used in Cargo.tomls before so it's probably more worth testing than =.

    Hope this is helpful. Thanks for creating a great tool.

    opened by eopb 6
  • Change how we handle user's directories

    Change how we handle user's directories

    closes #16, closes #26

    We will now use XDG directories system for *nix and the Known Folder system on Windows. When the directory is created, we will print where.

    opened by yozhgoor 4
  • Start an IDE instead of a shell

    Start an IDE instead of a shell

    @YohDeadfall make the point that some users use an IDE instead of a terminal for handle their Rust project's workflow.

    This issue will investigate some solutions to make that possible across all platforms already available.

    opened by yozhgoor 4
  • Updating clap and cargo-generate

    Updating clap and cargo-generate

    This PR addresses: https://github.com/yozhgoor/cargo-temp/issues/75 and https://github.com/yozhgoor/cargo-temp/issues/74

    Updating Clap and cargo-generate. According to the changelog we need to change parse(try_from_str to value_parser.

    I was not sure if you wanted to move to clap 4 or not, but I followed the version cargo-generate was using. Let me know if you want me to change it.

    Thank you :)

    opened by era 3
  • Cannot install on Windows

    Cannot install on Windows

    This is probably not a windows-specific issue, cargo install cargo-temp yields this error:

       Compiling cargo-temp v0.2.3
    error[E0432]: unresolved import `clap::Clap`
     --> C:\Users\angus\.cargo\registry\src\github.com-1ecc6299db9ec823\cargo-temp-0.2.3\src\lib.rs:3:5
      |
    3 | use clap::Clap;
      |     ^^^^^^^^^^ no `Clap` in the root
    
    error: cannot determine resolution for the derive macro `Clap`
      --> C:\Users\angus\.cargo\registry\src\github.com-1ecc6299db9ec823\cargo-temp-0.2.3\src\lib.rs:16:10
       |
    16 | #[derive(Clap, Debug)]
       |          ^^^^
       |
       = note: import resolution is stuck, try simplifying macro imports
    
    opened by CGMossa 2
  • Repository in dependencies

    Repository in dependencies

    Allow the user to add repository to their cargo.toml like this: repo = { git = "https://github.com/user/repo.git", branch = "main" }

    The user will create the temporary projet using the url of the repo like this: $ cargo-temp https://github.com/user/repo.git

    To select a branch, the user can add @branch=main at the end of the url. To select a revision, the user can add @rev=8e0f44a81 at the end of the url.

    If the user don't add any @, the default will be @main.

    opened by yozhgoor 2
  • Print a welcome message when creating a new temporary project

    Print a welcome message when creating a new temporary project

    • [x] Add a welcome_message setting to the config file to enable or disable the welcome message
    • [x] Print a welcome message when creating a new temporary project that explains how to exit and how to preserve the project when exiting.

    Closes #63

    opened by yozhgoor 1
  • Move the project to a different location if the project is preserved

    Move the project to a different location if the project is preserved

    Related to https://github.com/yozhgoor/cargo-temp/issues/71, it adds a new optional config key to move the projects to another path when they are preserved.

    I moved all the code related to the preservation of the directory to a new method so it can be called elsewhere if needed.

    opened by era 5
Releases(v0.2.14)
Owner
Yohan Boogaert
Junior Consultant Developer
Yohan Boogaert
A cargo subcommand for checking and applying updates to installed executables

cargo-update A cargo subcommand for checking and applying updates to installed executables Documentation Manpage Installation Firstly, ensure you have

наб 827 Jan 4, 2023
Cargo subcommand for running cargo without dev-dependencies.

cargo-no-dev-deps Cargo subcommand for running cargo without dev-dependencies. This is an extraction of the --no-dev-deps flag of cargo-hack to be use

Taiki Endo 5 Jan 12, 2023
A tool that allow you to run SQL-like query on local files instead of database files using the GitQL SDK.

FileQL - File Query Language FileQL is a tool that allow you to run SQL-like query on local files instead of database files using the GitQL SDK. Sampl

Amr Hesham 39 Mar 12, 2024
ClangQL is a tool that allow you to run SQL-like query on C/C++ Code instead of database files using the GitQL SDK

ClangQL - Clang AST Query Language ClangQL is a tool that allow you to run SQL-like query on C/C++ Code instead of database files using the GitQL SDK.

Amr Hesham 490 Oct 23, 2024
SKYULL is a command-line interface (CLI) in development that creates REST API project structure templates with the aim of making it easy and fast to start a new project.

SKYULL is a command-line interface (CLI) in development that creates REST API project structure templates with the aim of making it easy and fast to start a new project. With just a few primary configurations, such as project name, you can get started quickly.

Gabriel Michaliszen 4 May 9, 2023
A CLI utility installed as "ansi" to quickly get ANSI escape sequences. Supports the most basic ones, like colors and styles as bold or italic.

'ansi' - a CLI utility to quickly get ANSI escape codes This Rust project called ansi-escape-sequences-cli provides an executable called ansi which ca

Philipp Schuster 5 Jul 28, 2022
fas stand for Find all stuff and it's a go app that simplify the find command and allow you to easily search everything you nedd

fas fas stands for Find all stuff and it's a rust app that simplify the find command and allow you to easily search everything you need. Note: current

M4jrT0m 1 Dec 24, 2021
A rust library + CLI tool that tells you when swas will upload new video through complex calculations

A rust library + CLI tool that tells you when swas will upload new video through complex calculations. It also lets you search and play youtube videos of swas and other channels. Searching about youtube channels is also an option. Basically it's a youtube search cli tool written in rust.

midnightFirefly 4 Jun 10, 2022
A simple CLI tool to create python project file structure, written in Rust

Ezpie Create python projects blazingly fast What Ezpie can do? It can create a python project directory What kind of directory can Ezpie create? For c

Faseeh 3 Sep 29, 2023
Use Git installed in Bash on Windows/Windows Subsystem for Linux (WSL) from Windows and Visual Studio Code (VSCode)

WSLGit This project provides a small executable that forwards all arguments to git running inside Bash on Windows/Windows Subsystem for Linux (WSL). T

A. R. S. 1.1k Jan 3, 2023
A little tool to create region-free openingTitle.arc files for New Super Mario Bros. Wii, or to convert them from one region to another

smallworld ...though the mountains divide and the oceans are wide... smallworld is a little tool that can create region-free openingTitle.arc files fo

NSMBW Community 7 Feb 6, 2023
A utility for managing cargo dependencies from the command line.

cargo edit This tool extends Cargo to allow you to add, remove, and upgrade dependencies by modifying your Cargo.toml file from the command line. Curr

Pascal Hertleif 2.7k Jan 6, 2023
Shell Of A New Machine: Quickly configure new environments

Shell Of A New Machine soanm is a dead-simple tool for easily configuring new UNIX machines, with almost zero prerequisites on the target machine. All

Ben Weinstein-Raun 41 Dec 22, 2022
A simple, modern fuzzy finder tool to run examples in a Cargo project.

cargo-rx cargo-rx is a simple, modern Runner for Examples in a Cargo project. This crate provides a single executable: rx. Basically anywhere you woul

Ritvik Nag 14 Dec 2, 2022
Experimental Rust UI library for Audulus. "rui" is a temporary name.

Experimental Rust UI library for Audulus. "rui" is a temporary name.

Audulus LLC 1.1k Dec 28, 2022
🦀 Temporary repository for the rewrite of Smoothie in Rust

Warning As with a lot of projects, this one is also a WIP, expect broken code ?? smoothie-rs Temporary repository hosting the code for Smoothie's futu

Couleur Tweak Tips 6 Jan 22, 2023
Tool to allow parsing large JSON files without laoding into memory

Tool to allow parsing large JSON files without laoding into memory. Developed in Rust with adapters in other programming langauges for easy adoption

Salaah Amin 7 Jul 11, 2023
Utility to inherit dependencies from workspace file if it occurs 'n' or more times throughout the project.

Cargo Workspace Dependency Inheritor Utility that inherits dependencies from the main workspace if they occur n or more times in the workspace. Worksp

Timon 9 Oct 14, 2022
Temporary files and directories with UTF-8 paths.

camino-tempfile A secure, cross-platform, temporary file library for Rust with UTF-8 paths. This crate is a wrapper around tempfile that works with th

null 4 Apr 24, 2023