Quickly build cool CLI apps in Rust.

Overview

QuiCLI

Quickly build cool CLI apps in Rust.

Build Status Documentation License crates.io

Getting started

Read the Getting Started guide!

Thanks

This is only possible because of all the awesome libraries included here:

  • Structopt and Clap for the nice CLI with awesome argument handling, great error messages, and nice composability!
  • Serde for handling all things serializing and deserializing
  • failure for ergonomic error handling.
  • …and more to come!

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Comments
  • Requirements Discussion: what is quicli?

    Requirements Discussion: what is quicli?

    This is a discussion on what the use case and requirements of these two libraries are.

    stdcli's goal is basically to make creating a CLI in rust more like creating one in python from a user experience and ergonomics point of view. This means:

    • batteries included
    • almost everything you need is already imported
      • python, because of it's duct typing and general unsafetly, does not require you to import "something" to use methods on its types. Rust, on the other hand requires you to import a boatload of traits.
      • related: #18
    • "flush out" macros that should be in the stdlib like hashmap!
    • (not yet in stdcli but planned) provide feature flags to control which libraries you want so you can develop with "full batteries" and then pare everything down as your application dependencies become more clear. For instance, maybe ansi_term, pretty_tables, termstyle and tabwriter are all in the "full batteries" package, but then you can do features = ["style_termstyle"] to only have termstyle

    Also related: require that all versions in quicli are of the form >=VERSION so that the user can mostly control which version is used.

    What is quicli?

    Qui CLI seems to have similar but not completely overlapping goals. I would prefer we merge forces rather than create competing libraries.

    I think it should be possible through liberal use of feature flags to accomplish any usecase a user might want. I.e. features = "full_batteries" would depend-on-the-world, but features = "light" would give very minimal dependencies, and everything in between.

    looking for feedback 
    opened by vitiral 15
  • fix #43: pub use crates, add set_log_verbosity and feature=full-throttle

    fix #43: pub use crates, add set_log_verbosity and feature=full-throttle

    This does several things to, some of which is to integrate better with the ergo ecosystem.

    • Adds feature=full-throttle as suggested in #43, which allows disabling some of the included crates
    • Moves set_log_verbosity into a function so that users can more cleanly migrate away from the main! macro (I already had need of this in artifact).
    • Publically uses crates to improve the import story. For instance, to use clap (which is exported by quicli), I had to do: use quicli::prelude::structopt::clap, which now I can do use quicli::structopt::clap.

    I am currently using both ergo and quicli together to rewrite artifact's CLI. I'll keep opening bugs/PRs as I find them!

    opened by vitiral 14
  • add and export path_abs crate

    add and export path_abs crate

    I am the creator and maintainer of the new path_abs crate and I think it solves a lot of ergonomic problems in rust (problems I see you re-solving with the fs module!).

    Questions:

    • should we export path_abs types?
    • should fs module be deprecated?

    Thanks!

    maybe - use case needed 
    opened by vitiral 10
  • Publish fancy guides/docs

    Publish fancy guides/docs

    I want to add some more examples and show them in a nice way, but I'm not yet sure how best to do that.

    One idea:

    • Add docs/ folder that is deploy via Github Pages (with Jekyll)
    • put "literate Rust" in there (Markdown with code blocks)
    • parse the Markdown files in there with waltz and test that code as subcrate(s) on CI
    looking for feedback 
    opened by killercup 10
  • Allow mut args

    Allow mut args

    (in the most annoying way)

    This is useful for when you want to do more complicated manual defaults for arguments, such as trying to read from an environment variable if an argument is not provided.

    opened by CAD97 5
  • WIP: Structopt 0.2 without macro re-export in quicli

    WIP: Structopt 0.2 without macro re-export in quicli

    It doesn't look like I can get it to re-export the proc macro like I can for the proc-macro _derive crate.

    Since we already tell people to add structopt to their Cargo.toml, it's might not look like a big step to make them add #[macro_use] extern crate structopt; to their files, too. But still, this sadly is worse than what we have right now.

    cf. https://github.com/TeXitoi/structopt/pull/50#issuecomment-363039922

    cc @TeXitoi

    opened by killercup 5
  • Make head example main more concise

    Make head example main more concise

    Is this (more) readable? Can people new to Rust easily understand this code? Do they feel like they can write this themselves?

    main!(|args: Cli, log_level: verbosity| {
        read_file(&args.file)?
            .lines()
            .take(args.count)
            .for_each(|line| println!("{}", line));
    });
    
    opened by killercup 5
  • Replace examples with guides!

    Replace examples with guides!

    Also adds testing on CI. Rending this in some way other than on github.com will come at a later point.

    TODO

    Required to land this

    • [x] Set up waltz on Travis
    • [x] Move over Readme guide
    • [x] Move over commit guide

    Stretch goals

    • [ ] Cache target dir between crates generated waltz
    • [x] Set up github pages rendering with simple template
    • [ ] Move over image resize guide from #23

    cc #16

    opened by killercup 4
  • Expose remove_dir_all from crate with same name instead of std

    Expose remove_dir_all from crate with same name instead of std

    Before anything else, thanks for this very neat crate! With the logging, failure and struct-opt ready for use, it makes it really fast to start building quick and clean scripts. So thanks :)

    This PR aims at implementing #85

    opened by kimsnj 3
  • StructOpt not found in scope

    StructOpt not found in scope

    Hi,

    I wrote a simple toy example today but it seems by StructOpt declaration might be invalid - I have a few errors:

    error[E0425]: cannot find value `to` in this scope
      --> src\main.rs:24:17
       |
    24 | #[derive(Debug, StructOpt)]
       |                 ^^^^^^^^^
       |                 |
       |                 `self` value is only available in methods with `self` parameter
       |                 help: try: `self.to`
    
    error[E0425]: cannot find value `w` in this scope
      --> src\main.rs:24:17
       |
    24 | #[derive(Debug, StructOpt)]
       |                 ^^^^^^^^^ not found in this scope
    
    error[E0425]: cannot find value `from` in this scope
      --> src\main.rs:24:17
       |
    24 | #[derive(Debug, StructOpt)]
       |                 ^^^^^^^^^
       |                 |
       |                 `self` value is only available in methods with `self` parameter
       |                 help: try: `self.from`
    
    error[E0425]: cannot find value `r` in this scope
      --> src\main.rs:24:17
       |
    24 | #[derive(Debug, StructOpt)]
       |                 ^^^^^^^^^ not found in this scope
    
    error[E0425]: cannot find value `Fahrenheit` in this scope
      --> src\main.rs:24:17
       |
    24 | #[derive(Debug, StructOpt)]
       |                 ^^^^^^^^^ not found in this scope
    help: possible candidate is found in another module, you can import it into scope
       |
    7  | use TemperatureUnit::Fahrenheit;
    
    

    Here's the source code - https://gist.github.com/blakehawkins/5f848d3a4eff2f0a67282cc1cb730022

    Any advice appreciated! May be a regression?

    opened by blakehawkins 3
  • Integrate with the ergo ecosystem

    Integrate with the ergo ecosystem

    Hey @killercup, you've probably been waiting for this feature request πŸ˜„

    I am nearing completion of the initial release of ergo. There is a LOT of overlap between these two crates but there is also several areas that there is not overlap.

    My suggestion is to have a minimal feature set which only

    • exports the main! macro
    • exports log and envlog crates and types
    • exports structopt macro and types
    • exports failure macros and types

    This would allow quicli to fit cleanly within the ergo crate ecosystem, as I have no desire for ergo to perform these operations. Theoretically I could create an ergo-cli crate which is pretty much a fork of quicli with these features -- but I don't want to do that!

    Another advantage of this is that it could be part of the "story" of developing an application:

    • when you start out, use just quicli
    • when you need a larger stdlib, set features=minimal and import ergo
    • keep rusting!
    opened by vitiral 3
  • bail!() no longer works with quicli 0.4

    bail!() no longer works with quicli 0.4

    I think this is caused by https://github.com/rust-lang-nursery/failure/issues/258 and https://github.com/rust-lang-nursery/failure/issues/110, but I thought it worth mentioning, as I hit this upgrading from quicli 0.3 to 0.4.

    I'm not sure there's anything that can be done in this crate though, so feel free to close if you want.

    Reproduction:

    Source

    use quicli::prelude::*;
    
    fn main() -> CliResult {
        bail!("This does not work!");
    }
    

    Reproduction

    cargo new quicli_bail; cd quicli_bail
    cargo install cargo-edit
    cargo add quicli
    echo -e 'use quicli::prelude::*;\n\nfn main() -> CliResult {\n    bail!("This does not work!");\n}' >src/main.rs
    cargo build
    

    Result:

       Compiling test_quicli v0.1.0 (/Users/gib/tmp/test_quicli)
    error[E0308]: mismatched types
     --> src/main.rs:4:5
      |
    4 |     bail!("This doesn't work!");
      |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `exitfailure::ExitFailure`, found struct `failure::error::Error`
      |
      = note: expected type `exitfailure::ExitFailure`
                 found type `failure::error::Error`
      = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
    
    error: aborting due to previous error
    
    For more information about this error, try `rustc --explain E0308`.
    error: Could not compile `test_quicli`.
    
    To learn more, run the command again with --verbose.
    
    opened by gibfahn 1
  • Issue with glob in thumbnail tutorial

    Issue with glob in thumbnail tutorial

    After I finished the thumbnail tutorial, I tried to test it and got this error

    Error: No files match pattern `rust_memes/*`
    

    After seeing that, I progressively commented out more code to get a minimal reproduction, and I was able to find that this block of code doesn't match anything

    use quicli::prelude::*;
    
    fn main() -> CliResult {
        let files = glob("src/*")?;
        println!("{:?}", files);
        Ok(())
    }
    
    ~/dev/rust/thumbify master
    ❯ cargo run --
       Compiling thumbify v0.1.0 (/home/chris.pickard/dev/rust/thumbify)
        Finished dev [unoptimized + debuginfo] target(s) in 1.11s
         Running `target/debug/thumbify`
    Error: No files match pattern `src/*`
    

    Even though I clearly have matching files in my src/ directory

    ~/dev/rust/thumbify master
    ❯ ls src
    main.rs
    

    I'm sorry, I feel like I'm quite a thorn in your side at the moment

    bug 
    opened by chrispickard 2
  • Turn on logging in all subcrates?

    Turn on logging in all subcrates?

    As it is right now, the -vvv enables logging only for the main crate. For some use-cases, the ability to log everything would make more sense. Any way to achieve it?

    Right now even RUST_LOG no longer works.

    opened by dpc 2
  • Use the error! macro for failure.

    Use the error! macro for failure.

    I love quicli, here is a suggestion on how to improve it (in the form of a PR).

    Since we control the main method, there is no way that the logging init can fail. Given this, we can use the logging functionality for outputting any errors that are returned from the main method. This is what I have implemented in this PR.

    Apart from this, there are a few small improvements, for example removing a warning in an edge case where all paths lead to an error, and adding tests for the different forms of the main! macro.

    Let me know what you think!

    opened by derekdreery 1
  • human-panic

    human-panic

    Would it make sense for human-panic to be part of quicli? I feel it'd make a lot of sense for it to be part of almost every CLI application, but I'm not sure if it exceeds quicli's scope.

    I think it might be an interesting addition to consider. Keen to hear thoughts on this!

    Refs

    • https://github.com/yoshuawuyts/human-panic
    opened by yoshuawuyts 0
Releases(v0.4.0)
  • v0.4.0(Dec 6, 2018)

    This release is only compatible with Rust 1.31.0 and later.

    Added

    • The CliResult type alias was added as an easy to write type to be used as an return type in main functions. It uses the exitfailure crate internally.

    Removed

    • The Result type alias has been removed from the prelude.

      To migrate from 0.3, please replace Result<$X> with Result<$X, Error>.

    • Structopt is no longer re-exported.

      To migrate from 0.3, please add structopt = "0.2" to your Cargo.toml, and add use structopt::StructOpt; to your source files.

    • The main! macro has been removed. It was the cause of much confusion and was originally introduced to work around the lack of support for using the ? operator in the main function.

      To migrate from 0.3, you should use a regular main function like fn main() -> CliResult { Ok(()) }. You'll need to return Ok(()) at the end to indicate the program was successful.

      To get access to your CLI arguments, use let args = Cli::from_args(); (adjust the Cli name with the name of your struct that derives StructOpt.)

      To enable logging, it is easiest to add the line args.verbosity.setup_env_logger(&env!("CARGO_PKG_NAME"))?; right after the previous one loading the CLI arguments. You can also initialize a custom logger with the right log level directly by accessing args.verbosity.log_level().

    Source code(tar.gz)
    Source code(zip)
  • v0.3.1(Oct 3, 2018)

  • v0.3.0(Jun 10, 2018)

    0.3.0 - 2018-06-10

    Added

    • The full code of the example projects from the guides is now also available in the repository's examples/ directory.
    • A full-throttle feature was added and is enabled by default. Most dependencies are now optional and only available when this feature (or the dependency itself) is enabled. In practice, this means you can easily opt-out of default quicli features and only enable what you need.

    Fixed

    • Verbosity flag works for hyphenated package names

    Changed

    • prelude::LoggerBuiler has been renamed to prelude::LoggerBuilder

    • Now prints all causes after printing error in main!

    • Update rayon to 1.0

    • We now use the new clap-verbosity-flag crate for adding that -v flag:

      #[derive(Debug, StructOpt)]
      struct Cli {
          #[structopt(flatten)]
          verbosity: Verbosity,
      }
      
    Source code(tar.gz)
    Source code(zip)
  • v0.2.0(Feb 11, 2018)

    Fixed

    • The verbosity flag of the main! macro now actually works! (#45)

    Changed

    • Upgrade structopt to 0.2:
      • No need to add structopt to you dependencies anymore (just delete the line in the Cargo.toml)

      • Their handling of "occurrences of" parameters changed, so, for verbosity you now need to write:

        #[structopt(long = "verbosity", short = "v", parse(from_occurrences))]
        verbosity: u8,
        
    Source code(tar.gz)
    Source code(zip)
  • v0.1.4(Feb 9, 2018)

    Changed

    • Reverts "main! now uses the more permissive std::result::Result enum and std::error::Error trait." from 0.1.3 which broke existing code
    Source code(tar.gz)
    Source code(zip)
  • v0.1.3(Feb 1, 2018)

    • main! now uses the more permissive std::result::Result enum and std::error::Error trait.
    • Fixed a bunch of typos in the docs (thanks everyone!)
    • Extended the Getting Started guide
    Source code(tar.gz)
    Source code(zip)
  • v0.1.2(Jan 28, 2018)

  • v0.1.1(Jan 22, 2018)

    Added

    • Re-export log macros
    • Automatically set up env_logger in main!
    • main! parameter for Cli struct and its logging level field
    • Readme fixes
    • Expose fs module
    Source code(tar.gz)
    Source code(zip)
  • v0.1.0(Jan 22, 2018)

A visual canvas and virtual machine for writing assembly to build cool things. Create machines and connect them together.

Visual Assembly Canvas A highly visual assembly editor, infinite canvas for wiring blocks and machines together, bytecode virtual machine runnable nat

Phoomparin Mano 32 Oct 11, 2023
Helps cargo build and run apps for iOS

cargo-xcodebuild Helps cargo build and run apps for iOS. ?? βš™οΈ ?? Setup You need to install Xcode (NOT just Command Line Tools!), xcodegen, cargo-xcod

Igor Shaposhnik 29 Nov 22, 2022
a simple program that you can scrap, is shit and really simple but is cool.

if you want to run it you need to have installed curl by default scrap youtube, but you can change it, also change the number of threads and run: carg

pai 7 Oct 15, 2021
LL Cool Twitch Tools

LL Cool Twitch Tools Hit me up on my twitch channel This project is a playground twitch API playground for me.

Christopher N. KATOYI 9 Dec 23, 2022
Remember how cool smlinux was? It's now time to bring it back.

smbuilder Remember how cool smlinux was? It's now time to bring it back. What is smbuilder? In short, smbuilder (stylized as all lowercase) is an app

ezntek 3 Apr 11, 2023
A tool crate to quickly build rust command line application.

Falsework A tool crate to quickly build rust command line application.

Leon Ding 103 Dec 12, 2022
Build Abstract Syntax Trees and tree-walking models quickly in Rust.

astmaker Build Abstract Syntax Trees and tree-walking models quickly in Rust. Example This example creates an AST for simple math expressions, and an

David Delassus 100 Jun 5, 2023
A CLI screentime monitoring tool. Shows how much time are you using certain apps.

A screentime monitoring tool, shows how much time are you really using certain apps. It work nicely with i3status or py3status on I3 window manager fo

Piotr Czajka 6 Dec 8, 2022
Build Java applications without fighting your build tool. Drink some espresso.

Espresso Build Java applications without fighting your build tool. Drink some espresso. Features Modern Look & Feel Command line interface inspired by

Hunter LaFaille 5 Apr 2, 2024
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
CLI tool to quickly create React + Typescript + Tailwind projects

QUICK INIT CLI Tool to quickly create React projects with Tailwind automatically configured for use. Typescript is selected as default. If JS is to be

Oscar 5 Nov 3, 2022
β–β–‚β–†β–‡β–β–„β–ˆβ– Sparklines for Rust apps

rspark β–β–‚β–†β–‡β–β–„β–ˆβ– Sparklines for Rust apps. Rust port of https://github.com/holman/spark Usage Add this to your Cargo.toml: [dependencies] rspark = "0.2

Eugene R. 50 Jun 11, 2022
A simplified general-purpose queueing system for Rust apps.

A simplified general-purpose queueing system for Rust apps. Example // Create a new Redeez object, and define your queues let mut queues = Redeez::new

Miguel Piedrafita 11 Jan 16, 2023
A Nix template for full-stack web apps in Rust using Leptos

leptos-fullstack A Nix template for full-stack web apps in Rust using Leptos. Tech used: Leptos full-stack framework server functions ssr + hydration

Sridhar Ratnakumar 6 Aug 4, 2023
A diff-based data management language to implement unlimited undo, auto-save for games, and cloud-apps which needs to retain every change.

Docchi is a diff-based data management language to implement unlimited undo, auto-save for games, and cloud-apps which needs to save very often. User'

juzy 21 Sep 19, 2022
Following "ZK HACK III - Building On-chain Apps Off-chain Using RISC Zero"

RISC Zero Rust Starter Template Welcome to the RISC Zero Rust Starter Template! This template is intended to give you a starting point for building a

drCathieSo.eth 3 Dec 22, 2022
A CLI command to parse kustomize build result and notify it to GitLab

ksnotify A CLI command to parse kustomize build result and notify it to GitLab Caution This repository is under development status. What ksnotify does

null 7 Jan 2, 2023
A simple CLI to build VEXCode V5 Pro projects and download them to the V5 brain.

vexer A simple CLI to build VEXCode V5 Pro projects and download them to the V5 brain. (WIP) This currently is only tested on and only works on window

null 2 May 16, 2022
A CLI tool for CIs and build scripts, making file system based caching easy and correct (locking, eviction, etc.)

FS Dir Cache A CLI tool for CIs and build scripts, making file system based caching easy and correct (locking, eviction, etc.) When working on build s

Dawid CiΔ™ΕΌarkiewicz 5 Aug 29, 2023