mirror of
https://github.com/tealdeer-rs/tealdeer.git
synced 2026-08-09 09:49:10 +02:00
Implement --update flag
This commit is contained in:
parent
d321bef678
commit
83e5e3622c
2 changed files with 11 additions and 4 deletions
11
src/main.rs
11
src/main.rs
|
|
@ -60,6 +60,7 @@ To render a local file (for testing):
|
|||
|
||||
$ tldr --render /path/to/file.md
|
||||
";
|
||||
const ARCHIVE_URL: &'static str = "https://github.com/tldr-pages/tldr/archive/master.tar.gz";
|
||||
|
||||
|
||||
#[derive(Debug, RustcDecodable)]
|
||||
|
|
@ -119,8 +120,14 @@ fn main() {
|
|||
|
||||
// Update cache, pass through
|
||||
if args.flag_update {
|
||||
println!("Flag --update not yet implemented.");
|
||||
process::exit(1);
|
||||
let dl = Updater::new(ARCHIVE_URL);
|
||||
let copied = dl.update().unwrap_or_else(|e| {
|
||||
match e {
|
||||
TldrError::UpdateError(msg) => println!("Could not update cache: {}", msg),
|
||||
};
|
||||
process::exit(1);
|
||||
});
|
||||
println!("Cached {} tldr pages.", copied);
|
||||
}
|
||||
|
||||
// Render local file and exit
|
||||
|
|
|
|||
|
|
@ -43,9 +43,9 @@ pub struct Updater {
|
|||
|
||||
impl Updater {
|
||||
|
||||
pub fn new(url: String) -> Updater {
|
||||
pub fn new<S>(url: S) -> Updater where S: Into<String> {
|
||||
Updater {
|
||||
url: url,
|
||||
url: url.into(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue