• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

eugene-babichenko / fixit / 17872261678

19 Sep 2025 11:47PM UTC coverage: 90.214% (-0.02%) from 90.236%
17872261678

push

github

eugene-babichenko
simplify template rendering

6 of 7 new or added lines in 1 file covered. (85.71%)

802 of 889 relevant lines covered (90.21%)

372.99 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.89
/src/cmd/init.rs
1
use std::io::{stdout, Write};
2

3
use clap::{Parser, Subcommand};
4
use thiserror::Error;
5

6
#[derive(Parser)]
7
pub struct Cmd {
8
    // The name of the alias.
9
    #[arg(long, default_value = "fix")]
10
    name: String,
11
    /// The shell for which we generate the alias.
12
    #[command(subcommand)]
13
    shell: Shell,
14
}
15

16
#[derive(Subcommand)]
17
enum Shell {
18
    Bash,
19
    Fish,
20
    Zsh,
21
    Powershell,
22
}
23

24
#[derive(Debug, Error)]
25
#[error("failed to render the alias")]
26
pub struct Error(#[source] std::io::Error);
27

28
macro_rules! include_template {
29
    ($ext:literal) => {
30
        include_str!(concat!(
31
            env!("CARGO_MANIFEST_DIR"),
32
            "/templates/alias.",
33
            $ext
34
        ))
35
    };
36
}
37

38
pub fn run(cmd: Cmd) -> Result<(), Error> {
6✔
39
    let template = match cmd.shell {
6✔
40
        Shell::Bash => include_template!("sh"),
4✔
41
        Shell::Fish => include_template!("fish"),
1✔
42
        Shell::Zsh => include_template!("zsh"),
1✔
43
        // TODO design a workflow for using this powershell contraption
44
        // $PSDefaultParameterValues['Out-Default:OutVariable'] = 'env:FIXIT_PREVIOUS_CMD_OUTPUT'
45
        // this would allow us to do quick search with powershell regardless of having a compatible
46
        // emulator or multiplexer
NEW
47
        Shell::Powershell => include_template!("ps1"),
×
48
    };
49
    let alias = template.replacen("__name__", &cmd.name, 1);
6✔
50
    stdout().write(alias.as_bytes()).map(|_| ()).map_err(Error)
6✔
51
}
6✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc