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