From 5000b496ea0920bb67883ad397f14bb7d71daeb1 Mon Sep 17 00:00:00 2001 From: Tyler Cook <10459406+cilki@users.noreply.github.com> Date: Sun, 2 Jun 2024 14:04:07 -0500 Subject: [PATCH] wip: merge API and CLI crates --- .github/workflows/check.yml | 81 +++++++++++++++ .github/workflows/prepare_release.yml | 26 +++++ .github/workflows/release.yml | 113 +++++++++++++++++++++ .github/workflows/test.yml | 37 +++++++ .release-plz.toml | 16 +++ Cargo.lock | 50 ++++----- Cargo.toml | 34 +++++-- gantry-api/Dockerfile => Dockerfile | 0 gantry-api/Cargo.toml | 29 ------ gantry/Cargo.toml | 12 --- gantry/src/api.rs | 21 ---- gantry/src/cli.rs | 6 -- gantry/src/lib.rs | 1 - src/cli/mod.rs | 11 ++ gantry-api/src/main.rs => src/cli/serve.rs | 18 +--- {gantry-api/src => src}/currency/mod.rs | 0 {gantry-api/src => src}/currency/monero.rs | 21 +++- {gantry-api/src => src}/hosting/aws.rs | 0 {gantry-api/src => src}/hosting/mod.rs | 0 {gantry-api/src => src}/hosting/self.rs | 0 {gantry/src => src}/main.rs | 18 ++-- 21 files changed, 362 insertions(+), 132 deletions(-) create mode 100644 .github/workflows/check.yml create mode 100644 .github/workflows/prepare_release.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/test.yml create mode 100644 .release-plz.toml rename gantry-api/Dockerfile => Dockerfile (100%) delete mode 100644 gantry-api/Cargo.toml delete mode 100644 gantry/Cargo.toml delete mode 100644 gantry/src/api.rs delete mode 100644 gantry/src/cli.rs delete mode 100644 gantry/src/lib.rs create mode 100644 src/cli/mod.rs rename gantry-api/src/main.rs => src/cli/serve.rs (76%) rename {gantry-api/src => src}/currency/mod.rs (100%) rename {gantry-api/src => src}/currency/monero.rs (79%) rename {gantry-api/src => src}/hosting/aws.rs (100%) rename {gantry-api/src => src}/hosting/mod.rs (100%) rename {gantry-api/src => src}/hosting/self.rs (100%) rename {gantry/src => src}/main.rs (62%) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml new file mode 100644 index 0000000..b8eed2e --- /dev/null +++ b/.github/workflows/check.yml @@ -0,0 +1,81 @@ +name: check +permissions: + contents: read +# This configuration allows maintainers of this repo to create a branch and pull request based on +# the new branch. Restricting the push trigger to the main branch ensures that the PR only gets +# built once. +on: + push: + branches: [master] + pull_request: +# If new code is pushed to a PR branch, then cancel in progress workflows for that PR. Ensures that +# we don't waste CI time, and returns results quicker https://github.com/jonhoo/rust-ci-conf/pull/5 +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true +jobs: + fmt: + runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, 'chore: release')" + name: stable / fmt + steps: + - uses: actions/checkout@v4 + - name: Install stable + uses: dtolnay/rust-toolchain@stable + with: + components: rustfmt + - name: cargo fmt --check + run: cargo fmt --check + clippy: + runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, 'chore: release')" + name: ${{ matrix.toolchain }} / clippy + permissions: + contents: read + checks: write + strategy: + fail-fast: false + matrix: + # Get early warning of new lints which are regularly introduced in beta channels. + toolchain: [stable, beta] + steps: + - uses: actions/checkout@v4 + - name: Install ${{ matrix.toolchain }} + uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ matrix.toolchain }} + components: clippy + - name: cargo clippy + uses: giraffate/clippy-action@v1 + with: + reporter: 'github-pr-check' + github_token: ${{ secrets.GITHUB_TOKEN }} + doc: + runs-on: ubuntu-24.04 + if: "!contains(github.event.head_commit.message, 'chore: release')" + name: nightly / doc + steps: + - run: sudo apt-get install -y libpango1.0-dev libgraphene-1.0-dev + - uses: actions/checkout@v4 + - name: Install nightly + uses: dtolnay/rust-toolchain@nightly + - name: cargo doc + run: cargo doc --no-deps --all-features + env: + RUSTDOCFLAGS: --cfg docsrs + msrv: + runs-on: ubuntu-24.04 + if: "!contains(github.event.head_commit.message, 'chore: release')" + strategy: + matrix: + msrv: ["1.74.0"] + name: ubuntu / ${{ matrix.msrv }} + steps: + - run: sudo apt-get install -y libpango1.0-dev libgraphene-1.0-dev + - uses: actions/checkout@v4 + - name: Install ${{ matrix.msrv }} + uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ matrix.msrv }} + - name: cargo +${{ matrix.msrv }} check + run: cargo check diff --git a/.github/workflows/prepare_release.yml b/.github/workflows/prepare_release.yml new file mode 100644 index 0000000..3412323 --- /dev/null +++ b/.github/workflows/prepare_release.yml @@ -0,0 +1,26 @@ +name: prepare_release +permissions: + pull-requests: write + contents: write +on: + push: + branches: + - master + +jobs: + github: + runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, 'chore: release')" + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: dtolnay/rust-toolchain@stable + + - uses: MarcoIeni/release-plz-action@v0.5 + with: + command: release-pr + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..b8817e2 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,113 @@ +name: release +on: + push: + branches: + - master + +jobs: + github: + runs-on: ubuntu-24.04 + if: "contains(github.event.head_commit.message, 'chore: release')" + steps: + - run: sudo apt-get install -y libpango1.0-dev libgraphene-1.0-dev + + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: dtolnay/rust-toolchain@stable + + - uses: MarcoIeni/release-plz-action@v0.5 + with: + command: release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} + + linux: + name: linux / ${{ matrix.target }} + runs-on: ubuntu-latest + needs: github + strategy: + fail-fast: false + matrix: + target: + - aarch64-unknown-linux-gnu + - aarch64-unknown-linux-musl + - i686-unknown-linux-gnu + - x86_64-unknown-linux-gnu + - x86_64-unknown-linux-musl + steps: + - uses: actions/checkout@v4 + with: + fetch-tags: true + + - uses: actions-rs/cargo@v1 + with: + command: build + args: --release --target ${{ matrix.target }} + + - uses: actions/upload-artifact@v4 + with: + name: goldboot-${{ matrix.target }} + path: target/${{ matrix.target }}/release/gantry + + - name: Upload artifacts to release + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_REPO: ${{ github.repository }} + run: | + for tag in $(git tag --points-at HEAD); do + if cp target/${{ matrix.target }}/release/${tag%-*} ${tag%-*}_${{ matrix.target }}; then + gh release upload "${tag}" "${tag%-*}_${{ matrix.target }}" + fi + done + + docker: + runs-on: ubuntu-latest + needs: linux + steps: + - uses: actions/checkout@v4 + with: + fetch-tags: true + + - uses: docker/setup-qemu-action@v3 + + - uses: docker/setup-buildx-action@v3 + + - uses: actions/download-artifact@v4 + with: + name: gantry-x86_64-unknown-linux-musl + path: gantry/linux-amd64 + + - uses: actions/download-artifact@v4 + with: + name: gantry-aarch64-unknown-linux-musl + path: gantry/linux-arm64 + + - uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Find version tags + id: get_tags + run: | + for tag in $(git tag --points-at HEAD); do + echo "${tag%-*}=${tag##*-}" >>"$GITHUB_OUTPUT" + done + + - uses: docker/build-push-action@v5 + if: ${{ steps.get_tags.outputs.goldboot != '' }} + with: + context: . + platforms: linux/amd64,linux/arm64 #,linux/arm/v7 + push: true + tags: fossable/gantry:latest,fossable/gantry:${{ steps.get_tags.outputs.gantry }} + + - uses: peter-evans/dockerhub-description@v4 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + repository: fossable/gantry + diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..7745730 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,37 @@ +name: test +permissions: + contents: read +on: + push: + branches: [master] + pull_request: +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true +jobs: + required: + runs-on: ubuntu-24.04 + if: "!contains(github.event.head_commit.message, 'chore: release')" + name: ubuntu / ${{ matrix.toolchain }} + strategy: + matrix: + # run on stable and beta to ensure that tests won't break on the next version of the rust + # toolchain + toolchain: [stable, beta] + steps: + - run: sudo apt-get install -y libpango1.0-dev libgraphene-1.0-dev + - uses: actions/checkout@v4 + - name: Install ${{ matrix.toolchain }} + uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ matrix.toolchain }} + - name: cargo generate-lockfile + # enable this ci template to run regardless of whether the lockfile is checked in or not + if: hashFiles('Cargo.lock') == '' + run: cargo generate-lockfile + # https://twitter.com/jonhoo/status/1571290371124260865 + - name: cargo test --locked + run: cargo test --locked --all-features + # https://github.com/rust-lang/cargo/issues/6669 + - name: cargo test --doc + run: cargo test --locked --all-features --doc diff --git a/.release-plz.toml b/.release-plz.toml new file mode 100644 index 0000000..cb5ee88 --- /dev/null +++ b/.release-plz.toml @@ -0,0 +1,16 @@ +[changelog] +header = "# Changelog" +body = "Body" +trim = true +protect_breaking_commits = true +sort_commits = "newest" + +commit_parsers = [ + { message = "^.*: add", group = "Added" }, + { message = "^.*: support", group = "Added" }, + { message = "^.*: remove", group = "Removed" }, + { message = "^.*: delete", group = "Removed" }, + { message = "^test", group = "Fixed" }, + { message = "^fix", group = "Fixed" }, + { message = "^.*: fix", group = "Fixed" }, +] diff --git a/Cargo.lock b/Cargo.lock index c15af9e..8a5f7eb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "addr2line" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" dependencies = [ "gimli", ] @@ -176,9 +176,9 @@ dependencies = [ [[package]] name = "backtrace" -version = "0.3.71" +version = "0.3.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" +checksum = "17c6a35df3749d2e8bb1b7b21a976d82b15548788d2735b9d82f329268f71a11" dependencies = [ "addr2line", "cc", @@ -602,22 +602,11 @@ dependencies = [ [[package]] name = "gantry" -version = "0.1.0" -dependencies = [ - "clap", - "serde", - "tracing", - "tracing-subscriber", -] - -[[package]] -name = "gantry-api" -version = "0.1.0" +version = "0.0.1" dependencies = [ "anyhow", "axum", "clap", - "gantry", "monero 0.21.0", "monero-rpc", "redb", @@ -652,9 +641,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.28.1" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" +checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" [[package]] name = "h2" @@ -874,9 +863,9 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d8d52be92d09acc2e01dddb7fde3ad983fc6489c7db4837e605bc3fca4cb63e" +checksum = "7b875924a60b96e5d7b9ae7b066540b1dd1cbd90d1828f54c92e02a283351c56" dependencies = [ "bytes", "futures-channel", @@ -1125,11 +1114,10 @@ dependencies = [ [[package]] name = "native-tls" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" +checksum = "a8614eb2c83d59d1c8cc974dd3f920198647674a0a035e1af1fa58707e317466" dependencies = [ - "lazy_static", "libc", "log", "openssl", @@ -1172,9 +1160,9 @@ dependencies = [ [[package]] name = "object" -version = "0.32.2" +version = "0.35.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" +checksum = "b8ec7ab813848ba4522158d5517a6093db1ded27575b070f4177b8d12b41db5e" dependencies = [ "memchr", ] @@ -1316,9 +1304,9 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro2" -version = "1.0.84" +version = "1.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec96c6a92621310b51366f1e28d05ef11489516e93be030060e5fc12024a49d6" +checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" dependencies = [ "unicode-ident", ] @@ -1880,9 +1868,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.37.0" +version = "1.38.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787" +checksum = "ba4f4a02a7a80d6f274636f0aa95c7e383b912d41fe721a31f29e29698585a4a" dependencies = [ "backtrace", "bytes", @@ -1899,9 +1887,9 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" +checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 194139e..dc3d1ef 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,8 +1,28 @@ -[profile.release] -strip = true +[package] +name = "gantry" +description = "The gantry HTTP server and CLI" +version = "0.0.1" +edition = "2021" +license = "AGPL-3.0-only" +authors = ["Tyler Cook"] +readme = "README.md" +repository = "https://github.com/fossable/gantry" +rust-version = "1.74" -[workspace] -members = [ - "gantry", - "gantry-api", -] +[dependencies] +anyhow = "1.0.86" +axum = "0.7.5" +clap = { version = "4.5.4", features = ["string", "derive"] } +monero = "0.21.0" +monero-rpc = { version = "0.4.0", features = ["rpc_authentication"], optional = true } +redb = "2.1.0" +reqwest = { version = "0.12.4", features = ["json"] } +serde = { version = "1.0.203", features = ["derive"] } +tokio = { version = "1.37.0", features = ["full"] } +tokio_schedule = "0.3.1" +tracing = "0.1.40" +tracing-subscriber = { version = "0.3.18", features = ["env-filter"] } + +[features] +monero = ["dep:monero-rpc"] +aws = [] diff --git a/gantry-api/Dockerfile b/Dockerfile similarity index 100% rename from gantry-api/Dockerfile rename to Dockerfile diff --git a/gantry-api/Cargo.toml b/gantry-api/Cargo.toml deleted file mode 100644 index 776b9a3..0000000 --- a/gantry-api/Cargo.toml +++ /dev/null @@ -1,29 +0,0 @@ -[package] -name = "gantry-api" -description = "The gantry HTTP API" -version = "0.1.0" -edition = "2021" -license = "AGPL-3.0-only" -authors = ["Tyler Cook"] -readme = "README.md" -repository = "https://github.com/fossable/gantry" -rust-version = "1.74" - -[dependencies] -anyhow = "1.0.86" -axum = "0.7.5" -clap = { version = "4.5.4", features = ["string"] } -gantry = { path = "../gantry" } -monero = "0.21.0" -monero-rpc = { version = "0.4.0", features = ["rpc_authentication"], optional = true } -redb = "2.1.0" -reqwest = { version = "0.12.4", features = ["json"] } -serde = { version = "1.0.203", features = ["derive"] } -tokio = { version = "1.37.0", features = ["full"] } -tokio_schedule = "0.3.1" -tracing = "0.1.40" -tracing-subscriber = { version = "0.3.18", features = ["env-filter"] } - -[features] -monero = ["dep:monero-rpc"] -aws = [] diff --git a/gantry/Cargo.toml b/gantry/Cargo.toml deleted file mode 100644 index 078e92b..0000000 --- a/gantry/Cargo.toml +++ /dev/null @@ -1,12 +0,0 @@ -[package] -name = "gantry" -description = "CLI interface for the gantry API" -version = "0.1.0" -edition = "2021" - - -[dependencies] -clap = { version = "4.4.7", features = ["derive", "string"] } -serde = { version = "1.0.203", features = ["derive"] } -tracing = "0.1.40" -tracing-subscriber = { version = "0.3.18", features = ["env-filter"] } diff --git a/gantry/src/api.rs b/gantry/src/api.rs deleted file mode 100644 index 99de1a5..0000000 --- a/gantry/src/api.rs +++ /dev/null @@ -1,21 +0,0 @@ -use serde::{Deserialize, Serialize}; - -#[derive(Serialize, Deserialize, Debug)] -pub enum Currency { - Xmr, -} - -#[derive(Serialize, Deserialize, Debug)] -pub struct ProvisionAccountResponse { - /// Account ID (wallet address) - pub address: String, -} - -#[derive(Serialize, Deserialize, Debug)] -pub struct CurrentRatesResponse { - pub currency: Currency, - pub hour: u64, - pub day: u64, - pub month: u64, - pub year: u64, -} diff --git a/gantry/src/cli.rs b/gantry/src/cli.rs deleted file mode 100644 index 05594da..0000000 --- a/gantry/src/cli.rs +++ /dev/null @@ -1,6 +0,0 @@ -#[derive(clap::Subcommand, Debug)] -pub enum Commands { - /// Provision a new account - Provision {}, - Deprovision {}, -} diff --git a/gantry/src/lib.rs b/gantry/src/lib.rs deleted file mode 100644 index e5fdf85..0000000 --- a/gantry/src/lib.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod api; diff --git a/src/cli/mod.rs b/src/cli/mod.rs new file mode 100644 index 0000000..7632e1a --- /dev/null +++ b/src/cli/mod.rs @@ -0,0 +1,11 @@ +use self::serve::ServeArgs; + +pub mod serve; + +#[derive(clap::Subcommand, Debug, Clone)] +pub enum Commands { + /// Provision a new account + Provision {}, + Deprovision {}, + Serve(ServeArgs), +} diff --git a/gantry-api/src/main.rs b/src/cli/serve.rs similarity index 76% rename from gantry-api/src/main.rs rename to src/cli/serve.rs index d715efd..ba87d68 100644 --- a/gantry-api/src/main.rs +++ b/src/cli/serve.rs @@ -4,19 +4,15 @@ use axum::{ routing::{get, post}, Router, }; -use clap::Parser; +use clap::{Args, Parser}; use redb::{Database, TableDefinition}; use std::{env, process::ExitCode, sync::Arc}; use tokio::net::TcpListener; use tokio::spawn; use tracing::info; -pub mod currency; -pub mod hosting; - -#[derive(Parser, Debug)] -#[clap(author, version, about, long_about = None)] -struct CommandLine { +#[derive(Debug, Clone, Args)] +pub struct ServeArgs { bind: Option, datadir: Option, // #[cfg(feature = "monero")] @@ -31,13 +27,7 @@ pub struct AppState { monero: crate::currency::monero::MoneroState, } -#[tokio::main] -async fn main() -> Result { - let args = CommandLine::parse(); - tracing_subscriber::fmt() - .with_env_filter(tracing_subscriber::EnvFilter::from_default_env()) - .init(); - +pub async fn serve(args: &ServeArgs) -> Result { let state = AppState { db: Arc::new(Database::create(format!( "{}/app.db", diff --git a/gantry-api/src/currency/mod.rs b/src/currency/mod.rs similarity index 100% rename from gantry-api/src/currency/mod.rs rename to src/currency/mod.rs diff --git a/gantry-api/src/currency/monero.rs b/src/currency/monero.rs similarity index 79% rename from gantry-api/src/currency/monero.rs rename to src/currency/monero.rs index 1681f9c..bd81885 100644 --- a/gantry-api/src/currency/monero.rs +++ b/src/currency/monero.rs @@ -3,12 +3,12 @@ use axum::{ http::StatusCode, Json, }; -use gantry::api::ProvisionAccountResponse; use monero_rpc::{RpcClientBuilder, WalletClient}; use redb::TableDefinition; +use serde::{Deserialize, Serialize}; use tracing::{debug, info, instrument}; -use crate::{AppState, CommandLine}; +use crate::{cli::serve::ServeArgs, AppState, CommandLine}; #[derive(Clone, Debug)] pub struct MoneroState { @@ -16,7 +16,7 @@ pub struct MoneroState { } impl MoneroState { - pub async fn new(cli: &CommandLine) -> anyhow::Result { + pub async fn new(cli: &ServeArgs) -> anyhow::Result { debug!("Connecting to wallet RPC"); let wallet = RpcClientBuilder::new() .rpc_authentication(monero_rpc::RpcAuthentication::Credentials { @@ -34,6 +34,12 @@ impl MoneroState { } } +#[derive(Serialize, Deserialize, Debug)] +pub struct ProvisionAccountResponse { + /// Account ID (wallet address) + pub address: String, +} + // TODO proper rate limiting #[instrument(ret)] pub async fn provision( @@ -70,6 +76,15 @@ pub async fn scan(State(state): State) -> Result<(), StatusCode> { Ok(()) } +#[derive(Serialize, Deserialize, Debug)] +pub struct CurrentRatesResponse { + pub currency: Currency, + pub hour: u64, + pub day: u64, + pub month: u64, + pub year: u64, +} + #[instrument(ret)] pub async fn rates(State(state): State) -> Result<(), StatusCode> { Ok(()) diff --git a/gantry-api/src/hosting/aws.rs b/src/hosting/aws.rs similarity index 100% rename from gantry-api/src/hosting/aws.rs rename to src/hosting/aws.rs diff --git a/gantry-api/src/hosting/mod.rs b/src/hosting/mod.rs similarity index 100% rename from gantry-api/src/hosting/mod.rs rename to src/hosting/mod.rs diff --git a/gantry-api/src/hosting/self.rs b/src/hosting/self.rs similarity index 100% rename from gantry-api/src/hosting/self.rs rename to src/hosting/self.rs diff --git a/gantry/src/main.rs b/src/main.rs similarity index 62% rename from gantry/src/main.rs rename to src/main.rs index c189a42..0d9bf3d 100644 --- a/gantry/src/main.rs +++ b/src/main.rs @@ -1,7 +1,11 @@ use crate::cli::Commands; +use anyhow::Result; use clap::Parser; +use std::process::ExitCode; -mod cli; +pub mod cli; +pub mod currency; +pub mod hosting; #[derive(Parser, Debug)] #[clap(author, version, about, long_about = None)] @@ -10,20 +14,18 @@ struct CommandLine { command: Option, } -fn main() { - // Parse command line options before we configure logging so we can set the - // default level - let command_line = CommandLine::parse(); - - // Configure logging +#[tokio::main] +async fn main() -> Result { + let args = CommandLine::parse(); tracing_subscriber::fmt() .with_env_filter(tracing_subscriber::EnvFilter::from_default_env()) .init(); // Dispatch command - match &command_line.command { + match &args.command { Some(Commands::Provision {}) => todo!(), Some(Commands::Deprovision {}) => todo!(), + Some(Commands::Serve(args)) => crate::cli::serve::serve(args).await, None => todo!(), } }