-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e89f09a
commit 17ca869
Showing
4 changed files
with
105 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use std::path::PathBuf; | ||
use std::fs; | ||
|
||
use lvd::LvdFile; | ||
use clap::Clap; | ||
|
||
#[derive(Clap)] | ||
struct Args { | ||
in_file: PathBuf, | ||
out_file: PathBuf, | ||
} | ||
|
||
fn main() { | ||
let args = Args::parse(); | ||
|
||
match LvdFile::open(&args.in_file) { | ||
Ok(lvd_file) => { | ||
fs::write(&args.out_file, serde_yaml::to_string(&lvd_file).unwrap()).unwrap(); | ||
} | ||
Err(binrw::Error::BadMagic { .. }) => { | ||
// Magic doesn't match, is a yaml file | ||
let contents = fs::read_to_string(&args.in_file).unwrap(); | ||
let lvd_file: LvdFile = serde_yaml::from_str(&contents).unwrap(); | ||
|
||
lvd_file.save(&args.out_file).unwrap(); | ||
} | ||
Err(err) => { | ||
eprintln!("Error: {:?}", err); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters