Skip to content

Commit

Permalink
chore: run cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
SyedAhkam committed Aug 12, 2023
1 parent 8455904 commit 49bb3a6
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
14 changes: 10 additions & 4 deletions src/commands/create.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use anyhow::{Context, Result, anyhow};
use anyhow::{anyhow, Context, Result};
use clap::Parser;

use std::{collections::BTreeMap, path::PathBuf};
Expand Down Expand Up @@ -49,9 +49,15 @@ fn get_vars(args: &Create) -> Result<BTreeMap<String, String>> {
// FIXME: this is a hack, we should use a proper parser
let get_package_id = |package_id: String| {
let mut parts = package_id.split('.');
let domain = parts.next().ok_or_else(|| anyhow!("domain part missing in package"))?;
let org = parts.next().ok_or_else(|| anyhow!("org part missing in package"))?;
let name = parts.next().ok_or_else(|| anyhow!("name part missing in package"))?;
let domain = parts
.next()
.ok_or_else(|| anyhow!("domain part missing in package"))?;
let org = parts
.next()
.ok_or_else(|| anyhow!("org part missing in package"))?;
let name = parts
.next()
.ok_or_else(|| anyhow!("name part missing in package"))?;

anyhow::Ok((domain.to_owned(), org.to_owned(), name.to_owned()))
};
Expand Down
2 changes: 1 addition & 1 deletion src/commands/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pub mod create;
pub mod build;
pub mod create;
pub mod install;
pub mod run;
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ enum SubCommand {
Create(commands::create::Create),
Build(commands::build::Build),
Install(commands::install::Install),
Run(commands::run::Run)
Run(commands::run::Run),
}

fn main() {
Expand All @@ -31,7 +31,7 @@ fn main() {
SubCommand::Create(args) => commands::create::handle(args),
SubCommand::Build(args) => commands::build::handle(args),
SubCommand::Install(args) => commands::install::handle(args),
SubCommand::Run(args) => commands::run::handle(args)
SubCommand::Run(args) => commands::run::handle(args),
};

if result.is_err() {
Expand Down
12 changes: 7 additions & 5 deletions src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#![allow(dead_code)]

use anyhow::{Result, Context};
use anyhow::{Context, Result};
use which::which;

pub fn prompt_for_input(prompt: &str) -> Result<String> {
Ok(dialoguer::Input::<String>::with_theme(&dialoguer::theme::ColorfulTheme::default())
.with_prompt(prompt)
.interact_text()
.context("failed to prompt user")?)
Ok(
dialoguer::Input::<String>::with_theme(&dialoguer::theme::ColorfulTheme::default())
.with_prompt(prompt)
.interact_text()
.context("failed to prompt user")?,
)
}

pub fn find_gradle() -> Option<String> {
Expand Down

0 comments on commit 49bb3a6

Please sign in to comment.