Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
fail-fast: false
matrix:
include:
- os: macos-13
- os: macos-15-intel
target: x86_64-apple-darwin
- os: macos-latest
target: aarch64-apple-darwin
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,32 @@ jobs:
fail-fast: false
matrix:
include:
- os: macos-latest
- os: macos-15-intel
target: x86_64-apple-darwin
- os: macos-latest
target: aarch64-apple-darwin
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: ubuntu-latest
target: i686-unknown-linux-gnu
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
- os: windows-latest
target: x86_64-pc-windows-msvc
- os: windows-latest
target: i686-pc-windows-msvc
# - i686-pc-windows-gnu
# - x86_64-pc-windows-gnu
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install rust
uses: dtolnay/rust-toolchain@1.88.0
with:
target: ${{ matrix.target }}
- name: Install linker
if: matrix.target == 'i686-unknown-linux-gnu'
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install gcc-multilib
sudo apt-get install musl-tools gcc-multilib
- name: Checkout
uses: actions/checkout@v4
- name: Test
run: cargo test --target ${{ matrix.target }}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Please see [CHANGELOG.md](CHANGELOG.md).
<!-- omit from toc -->
## Contributing

Contributions and feedback are welcome! Feel free to open an issue or submit a pull request. See [CONTRIBUTING.md](CONTRIBUTING.md) for more details. Here is a list of [Contributors](http://github.com/automa/cli/contributors).
Contributions and feedback are welcome! Feel free to open an issue or submit a pull request. See [CONTRIBUTING.md](CONTRIBUTING.md) for more details. Here is a list of [Contributors](https://github.com/automa/cli/contributors).

<!-- omit from toc -->
## License
Expand All @@ -81,4 +81,4 @@ MIT
<!-- omit from toc -->
## Bug Reports

Report [here](http://github.com/automa/cli/issues).
Report [here](https://github.com/automa/cli/issues).
2 changes: 1 addition & 1 deletion src/dev.rs → src/commands/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub struct Dev {}

impl Dev {
#[instrument(name = "dev", skip_all)]
pub fn run(self) -> Result {
pub(crate) fn run(&self) -> Result {
Ok(())
}
}
18 changes: 18 additions & 0 deletions src/commands/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use clap::Parser;

use crate::error::Result;

pub mod dev;

#[derive(Debug, Parser)]
pub enum Subcommands {
Dev(dev::Dev),
}

impl Subcommands {
pub(crate) fn run(&self) -> Result {
match self {
Self::Dev(x) => x.run(),
}
}
}
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub fn finish(result: Result) {
exit(code);
}

pub fn exit(code: Code) {
pub fn exit(code: Code) -> ! {
stdout().flush().unwrap();
stderr().flush().unwrap();

Expand Down
51 changes: 51 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
use clap::Parser;
use clap_verbosity_flag::{InfoLevel, Verbosity};
use colorchoice_clap::Color;

use crate::{commands::Subcommands, error::Result};

pub mod error;
mod styles;

pub mod commands;

/// CLI for Automa
#[derive(Debug, Parser)]
#[clap(name = "automa", version)]
#[command(styles = styles::styles())]
pub struct App {
#[command(subcommand)]
pub cmd: Subcommands,

#[command(flatten)]
pub color: Color,

#[command(flatten)]
pub verbose: Verbosity<InfoLevel>,
}

impl App {
pub fn run(self) -> Result {
self.cmd.run()
}

pub fn new(cmd: Subcommands) -> Self {
App {
cmd,
color: Color::default(),
verbose: Verbosity::default(),
}
}
}

#[cfg(test)]
mod test {
use super::*;

use clap::CommandFactory;

#[test]
fn verify_app() {
App::command().debug_assert();
}
}
44 changes: 2 additions & 42 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,36 +1,10 @@
use std::io::stdout;

use anstream::{AutoStream, ColorChoice};
use automa_cli::{App, error};
use clap::Parser;
use clap_verbosity_flag::{InfoLevel, Verbosity};
use colorchoice_clap::Color;
use tracing_subscriber::prelude::*;

mod error;
mod styles;

mod dev;

/// CLI for Automa
#[derive(Debug, Parser)]
#[clap(name = "automa", version)]
#[command(styles = styles::styles())]
struct App {
#[command(subcommand)]
cmd: Subcommands,

#[command(flatten)]
color: Color,

#[command(flatten)]
verbose: Verbosity<InfoLevel>,
}

#[derive(Debug, Parser)]
enum Subcommands {
Dev(dev::Dev),
}

fn main() {
let program = App::parse();

Expand All @@ -46,21 +20,7 @@ fn main() {
)
.init();

let result = match program.cmd {
Subcommands::Dev(x) => x.run(),
};
let result = program.run();

error::finish(result);
}

#[cfg(test)]
mod test {
use super::*;

use clap::CommandFactory;

#[test]
fn verify_app() {
App::command().debug_assert();
}
}
2 changes: 1 addition & 1 deletion src/styles.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use clap::builder::{Styles, styling::AnsiColor};

pub fn styles() -> Styles {
pub(crate) fn styles() -> Styles {
Styles::styled()
.header(AnsiColor::BrightYellow.on_default())
.usage(AnsiColor::BrightYellow.on_default())
Expand Down