2019-04-11 15:23:14 -07:00
|
|
|
use crate::common::*;
|
2016-10-23 16:43:52 -07:00
|
|
|
|
2019-10-09 00:18:53 -07:00
|
|
|
pub fn run() -> Result<(), i32> {
|
2018-05-06 19:02:17 -07:00
|
|
|
#[cfg(windows)]
|
2019-10-09 00:18:53 -07:00
|
|
|
ansi_term::enable_ansi_support().ok();
|
2018-05-06 19:02:17 -07:00
|
|
|
|
2018-08-27 16:03:52 -07:00
|
|
|
env_logger::Builder::from_env(
|
2018-12-08 14:29:41 -08:00
|
|
|
env_logger::Env::new()
|
|
|
|
.filter("JUST_LOG")
|
|
|
|
.write_style("JUST_LOG_STYLE"),
|
|
|
|
)
|
|
|
|
.init();
|
2018-08-27 16:03:52 -07:00
|
|
|
|
2019-10-07 02:06:45 -07:00
|
|
|
let app = Config::app();
|
2019-07-18 21:58:06 -07:00
|
|
|
|
2020-03-31 00:00:05 -07:00
|
|
|
info!("Parsing command line arguments…");
|
2019-07-18 21:58:06 -07:00
|
|
|
let matches = app.get_matches();
|
2016-10-23 16:43:52 -07:00
|
|
|
|
Gargantuan refactor (#522)
- Instead of changing the current directory with `env::set_current_dir`
to be implicitly inherited by subprocesses, we now use
`Command::current_dir` to set it explicitly. This feels much better,
since we aren't dependent on the implicit state of the process's
current directory.
- Subcommand execution is much improved.
- Added a ton of tests for config parsing, config execution, working
dir, and search dir.
- Error messages are improved. Many more will be colored.
- The Config is now onwed, instead of borrowing from the arguments and
the `clap::ArgMatches` object. This is a huge ergonomic improvement,
especially in tests, and I don't think anyone will notice.
- `--edit` now uses `$VISUAL`, `$EDITOR`, or `vim`, in that order,
matching git, which I think is what most people will expect.
- Added a cute `tmptree!{}` macro, for creating temporary directories
populated with directories and files for tests.
- Admitted that grammer is LL(k) and I don't know what `k` is.
2019-11-09 21:43:20 -08:00
|
|
|
let config = Config::from_matches(&matches).eprint(Color::auto())?;
|
2016-12-30 00:09:35 -08:00
|
|
|
|
Gargantuan refactor (#522)
- Instead of changing the current directory with `env::set_current_dir`
to be implicitly inherited by subprocesses, we now use
`Command::current_dir` to set it explicitly. This feels much better,
since we aren't dependent on the implicit state of the process's
current directory.
- Subcommand execution is much improved.
- Added a ton of tests for config parsing, config execution, working
dir, and search dir.
- Error messages are improved. Many more will be colored.
- The Config is now onwed, instead of borrowing from the arguments and
the `clap::ArgMatches` object. This is a huge ergonomic improvement,
especially in tests, and I don't think anyone will notice.
- `--edit` now uses `$VISUAL`, `$EDITOR`, or `vim`, in that order,
matching git, which I think is what most people will expect.
- Added a cute `tmptree!{}` macro, for creating temporary directories
populated with directories and files for tests.
- Admitted that grammer is LL(k) and I don't know what `k` is.
2019-11-09 21:43:20 -08:00
|
|
|
config.run_subcommand()
|
2016-10-23 16:43:52 -07:00
|
|
|
}
|