Skip to content

Commit

Permalink
Fixing #64 try to open r2pipe if no argument is provided
Browse files Browse the repository at this point in the history
  • Loading branch information
kriw authored and Anton Kochkov committed Jun 18, 2019
1 parent c719134 commit e605fe4
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions radeco/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,21 +162,27 @@ fn main() {
let mut rl = Editor::with_config(config);
rl.set_helper(Some(Completes::default()));
core::PROJ.with(move |proj| {
let proj_result = arg.map(|ref s| {
if scheme::is_http(s) {
core::load_proj_http(&s[scheme::HTTP.len()..], max_it).map_err(|e| e.to_string())
} else if scheme::is_tcp(s) {
core::load_proj_tcp(&s[scheme::TCP.len()..], max_it).map_err(|e| e.to_string())
} else if is_file(s) {
Ok(core::load_proj_by_path(s, max_it))
} else {
Err(format!("Invalid argument {}", s))
use r2pipe::R2Pipe;
let proj_result = match arg {
Some(ref s) if scheme::is_http(s) => {
core::load_proj_http(&s[scheme::HTTP.len()..], max_it)
.map_err(|e| Some(e.to_string()))
}
});
Some(ref s) if scheme::is_tcp(s) => {
core::load_proj_tcp(&s[scheme::TCP.len()..], max_it)
.map_err(|e| Some(e.to_string()))
}
Some(ref s) if is_file(s) => Ok(core::load_proj_by_path(s, max_it)),
Some(s) => Err(Some(format!("Invalid argument {}", s))),
None => match R2Pipe::open() {
Ok(r2p) => Ok(core::load_project_by_r2pipe(r2p, max_it)),
Err(_) => Err(None),
},
};
match proj_result {
Some(Ok(p)) => *proj.borrow_mut() = Some(p),
Some(Err(ref err)) => println!("{}", err),
None => {}
Ok(p) => *proj.borrow_mut() = Some(p),
Err(Some(ref err)) => println!("{}", err),
Err(None) => {}
}
});

Expand Down

0 comments on commit e605fe4

Please sign in to comment.