Skip to content

Commit

Permalink
b: application::use_case -> application::command
Browse files Browse the repository at this point in the history
  • Loading branch information
bouzuya committed Nov 3, 2021
1 parent 4199831 commit e54c279
Show file tree
Hide file tree
Showing 12 changed files with 16 additions and 18 deletions.
7 changes: 7 additions & 0 deletions b/crates/application/src/command.rs
@@ -0,0 +1,7 @@
mod list;
mod new;
mod view;

pub use self::list::list;
pub use self::new::new;
pub use self::view::view;
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion b/crates/application/src/lib.rs

This file was deleted.

19 changes: 9 additions & 10 deletions b/crates/application/src/main.rs
@@ -1,10 +1,11 @@
use ::use_case::{HasBRepository, HasListUseCase, HasViewUseCase};
mod command;

use adapter_fs::FsBRepository;
use b::use_case;
use entity::BId;
use limited_date_time::TimeZoneOffset;
use std::{io, path::PathBuf, str::FromStr};
use structopt::{clap::Shell, StructOpt};
use use_case::{HasBRepository, HasListUseCase, HasViewUseCase};

#[derive(Debug, StructOpt)]
struct Opt {
Expand Down Expand Up @@ -87,10 +88,8 @@ struct Config {
fn build_app(config: Config) -> anyhow::Result<App> {
let data_dir = config.data_dir;
let time_zone_offset = TimeZoneOffset::from_str(config.time_zone_offset.as_str())?;
let repository = FsBRepository::new(data_dir, time_zone_offset);
let app = App {
brepository: repository,
};
let brepository = FsBRepository::new(data_dir, time_zone_offset);
let app = App { brepository };
Ok(app)
}

Expand All @@ -112,21 +111,21 @@ fn main() -> anyhow::Result<()> {
data_dir,
time_zone_offset: time_zone_offset.unwrap_or(default_time_zone_offset),
})?;
use_case::list(&app, json, query, &mut io::stdout())
command::list(&app, json, query, &mut io::stdout())
}
Subcommand::New {
data_file,
template,
} => {
// TODO: use App
use_case::new(data_file, template)
command::new(data_file, template)
}
Subcommand::View { data_dir, id } => {
let app = build_app(Config {
data_dir,
time_zone_offset: default_time_zone_offset,
})?;
use_case::view(&app, id, &mut io::stdout())
command::view(&app, id, &mut io::stdout())
}
}
}
Expand Down Expand Up @@ -205,7 +204,7 @@ mod tests {
let app = App {
brepository: repository,
};
use_case::view(&app, bid, &mut output).unwrap();
command::view(&app, bid, &mut output).unwrap();
assert_eq!(output, b"Hello, world!");
Ok(())
}
Expand Down
7 changes: 0 additions & 7 deletions b/crates/application/src/use_case.rs

This file was deleted.

0 comments on commit e54c279

Please sign in to comment.