Skip to content
This repository has been archived by the owner on Aug 17, 2021. It is now read-only.

Use mod.rs for big modules and move main code into a library #10

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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 src/args.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use clap::{clap_app, crate_version, AppSettings};

pub fn get() -> clap::App<'static, 'static> {
pub fn args_get() -> clap::App<'static, 'static> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally prefer leaving it as get(), since that along with not reexporting the modules will make the function call look like args::get() instead of args::args_get() which is cleaner to me.

clap_app!(rawrscope =>
(global_setting: AppSettings::DisableHelpSubcommand)
(global_setting: AppSettings::VersionlessSubcommands)
Expand Down
File renamed without changes.
16 changes: 4 additions & 12 deletions src/main.rs → src/bin/main.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
#![windows_subsystem = "windows"]

mod args;
mod audio;
mod commands;
mod config;
mod panic;
mod render;
mod scope;
mod state;
mod ui;
use rawrscope::*;

fn main() {
let matches = args::get().get_matches();
let matches = args_get().get_matches();

let colors = fern::colors::ColoredLevelConfig::new();
let level_filter = match matches.occurrences_of("VERBOSE") {
Expand All @@ -35,8 +27,8 @@ fn main() {
.expect("could not initialize logging"); // TODO dont panic?

match matches.subcommand_name() {
None => commands::app::run(matches.value_of("PROJECT")),
Some("configure_audio") => commands::configure_audio::run(),
None => app::run(matches.value_of("PROJECT")),
Some("configure_audio") => configure_audio::run(),
_ => unimplemented!(),
}
}
File renamed without changes.
22 changes: 22 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

mod args;
mod audio;
mod commands;
mod config;
mod panic;
mod render;
mod scope;
mod state;
mod ui;

pub use {
args::*,
audio::*,
commands::*,
config::*,
panic::*,
render::*,
scope::*,
state::*,
ui::*,
};
Comment on lines +2 to +22
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would prefer just making the modules public instead of reexporting their contents. Will require adding an extra level to all of the function calls in main.rs

File renamed without changes.