14
Cargo.lock
generated
14
Cargo.lock
generated
@ -37,9 +37,10 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "awatch"
|
||||
version = "0.1.0"
|
||||
version = "0.3.1"
|
||||
dependencies = [
|
||||
"alphanumeric-sort",
|
||||
"colored",
|
||||
"failure",
|
||||
"failure_derive",
|
||||
"lazy_static",
|
||||
@ -107,6 +108,17 @@ dependencies = [
|
||||
"vec_map",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "colored"
|
||||
version = "1.9.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f4ffc801dacf156c5854b9df4f425a626539c3a6ef7893cc0c5084a23f0b6c59"
|
||||
dependencies = [
|
||||
"atty",
|
||||
"lazy_static",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "failure"
|
||||
version = "0.1.7"
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "awatch"
|
||||
version = "0.1.0"
|
||||
version = "0.3.1"
|
||||
authors = ["Pavel Kirilin <win10@list.ru>"]
|
||||
edition = "2018"
|
||||
|
||||
@ -18,3 +18,4 @@ alphanumeric-sort = "1.0.12" # Used to search for videos.
|
||||
regex = "1" # Regular expressions.
|
||||
termion = "1.5.5" # For interacting with terminal.
|
||||
term_grid = "0.1.7" # For showing matched files while initialization
|
||||
colored = "1.9" # For terminal coloring
|
@ -20,4 +20,6 @@ pub enum RunMode {
|
||||
Next,
|
||||
#[structopt(name = "update", about = "Update saved config")]
|
||||
Update,
|
||||
#[structopt(name = "reset", about = "Set episode to 0")]
|
||||
Reset,
|
||||
}
|
@ -15,6 +15,7 @@ use structopt::StructOpt;
|
||||
|
||||
use crate::run_modes::run;
|
||||
use crate::result::AppResult;
|
||||
use colored::{Colorize, Color};
|
||||
|
||||
pub mod result;
|
||||
pub mod config;
|
||||
@ -26,6 +27,12 @@ include!("cli.rs");
|
||||
|
||||
fn main() -> AppResult<()> {
|
||||
let opt: Opt = Opt::from_args();
|
||||
run(opt)?;
|
||||
if let Err(error) = run(opt) {
|
||||
println!("{dashes} {title} {dashes}",
|
||||
dashes = "#######".color(Color::BrightRed),
|
||||
title= "Error".color(Color::BrightRed)
|
||||
);
|
||||
println!("{}", error);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ pub enum AppError {
|
||||
StdErr(String),
|
||||
#[fail(display = "Config processing failed: {}", _0)]
|
||||
ParseError(String),
|
||||
#[fail(display = "Error was found: {}", _0)]
|
||||
#[fail(display = "{}", _0)]
|
||||
RuntimeError(String),
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@ use crate::{Opt, RunMode};
|
||||
use crate::result::{AppResult, AppError};
|
||||
use crate::initialization::init_config;
|
||||
use crate::config::{update_episode, update_config, Config};
|
||||
use std::process::{Command};
|
||||
use std::process::Command;
|
||||
|
||||
pub fn run(opts: Opt) -> AppResult<()> {
|
||||
let mode = opts.mode.unwrap_or_else(|| RunMode::Play);
|
||||
@ -22,6 +22,9 @@ pub fn run(opts: Opt) -> AppResult<()> {
|
||||
RunMode::Update => {
|
||||
update_config()
|
||||
}
|
||||
RunMode::Reset => {
|
||||
update_episode(|_| { Ok(0) })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -124,7 +124,6 @@ pub fn read_tty_line(
|
||||
Key::Char(c) => {
|
||||
buffer.insert(current_pos - 1, c.clone());
|
||||
current_pos += 1;
|
||||
println!("{:#?}", c);
|
||||
}
|
||||
Key::Backspace => {
|
||||
if let Some(pos) = current_pos.checked_sub(2) {
|
||||
|
Reference in New Issue
Block a user