1use anyhow::{Context, Error, Result};
2use helix_term::application::Application;
3use helix_term::args::Args;
4use helix_term::config::Config;
5use helix_term::keymap::merge_keys;
8fn setup_logging(logpath: PathBuf, verbosity: u64) -> Result<()> {
9 let mut base_config = fern::Dispatch::new();
11 base_config = match verbosity {
12 0 => base_config.level(log::LevelFilter::Warn),
13 1 => base_config.level(log::LevelFilter::Info),
14 2 => base_config.level(log::LevelFilter::Debug),
15 _3_or_more => base_config.level(log::LevelFilter::Trace),
18 // Separate file config so we can include year, month and day in file logs
19 let file_config = fern::Dispatch::new()
20 .format(|out, message, record| {
21 out.finish(format_args!(
23 chrono::Local::now().format("%Y-%m-%dT%H:%M:%S%.3f"),
29 .chain(fern::log_file(logpath)?);
31 base_config.chain(file_config).apply()?;
37async fn main() -> Result<()> {
38 let cache_dir = helix_core::cache_dir();
39 if !cache_dir.exists() {
40 std::fs::create_dir_all(&cache_dir).ok();
43 let logpath = cache_dir.join("helix.log");
54 <files>... Sets the input file to use
57 -h, --help Prints help information
58 -v Increases logging verbosity each use for up to 3 times
60 -V, --version Prints version information
62 env!("CARGO_PKG_NAME"),
63 env!("CARGO_PKG_VERSION"),
64 env!("CARGO_PKG_AUTHORS"),
65 env!("CARGO_PKG_DESCRIPTION"),
69 let args = Args::parse_args().context("could not parse arguments")?;
71 // Help has a higher priority and should be handled separately.
72 if args.display_help {
74 std::process::exit(0);
77 if args.display_version {
78 println!("helix {}", env!("CARGO_PKG_VERSION"));
79 std::process::exit(0);
82 let conf_dir = helix_core::config_dir();
83 if !conf_dir.exists() {
84 std::fs::create_dir_all(&conf_dir).ok();
87 let config = match std::fs::read_to_string(conf_dir.join("config.toml")) {
88 Ok(config) => merge_keys(toml::from_str(&config)?),
89 Err(err) if err.kind() == std::io::ErrorKind::NotFound => Config::default(),
90 Err(err) => return Err(Error::new(err)),
93 setup_logging(logpath, args.verbosity).context("failed to initialize logging")?;
95 // TODO: use the thread local executor to spawn the application task separately from the work pool
96 let mut app = Application::new(args, config).context("unable to create new application")?;
97 app.run().await.unwrap();
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list