Subject | Hash | Author | Date (UTC) |
---|---|---|---|
Revise `hide` command. | 482bad08f949eaedbd61e2cb7c53870271d47997 | Jan Allersma | 2019-01-11 15:45:26 |
Rename project to 'Ambassade'. | 4f9c0e27ca25042a97acebc9f3282e4f941706fe | Jan Allersma | 2019-01-10 15:01:39 |
Git integration. | 0ebc5b3769e50c3463bdc39af0160c7db0d3f00b | Jan Allersma | 2019-01-03 17:34:18 |
Implement `hide` command. | ab693b8fd91c93dfd7ee7b82cbae75b2a6043b0f | Jan Allersma | 2018-12-29 15:13:25 |
Resolve missing/erroneous build/run commands. | e81d57882036a6475718b0653169c609d23b1c30 | Jan Allersma | 2018-12-25 13:06:00 |
Show working directory in status. | ab188603dda062de4b2ea76c5bc1d2d41d98b8c2 | Jan Allersma | 2018-12-25 10:36:35 |
Add shell fallthrough. | 02078135791fb3889152c11defaa2df21d0ae597 | Jan Allersma | 2018-12-22 19:47:36 |
Show dependencies when using `delete` command. | cfa9779714d5e6d46ab5b4eeb84a915a15f23f54 | Jan Allersma | 2018-12-20 15:46:05 |
Resolve dep-tree by building project recursively. | f53e38d790ec67d99ec8204af97273a53b73a9dc | Jan Allersma | 2018-12-19 14:54:07 |
Improve `dep-tree` command. | 90bfa0340b7b874d65c08dc05c3d711abda1c469 | Jan Allersma | 2018-12-17 20:10:14 |
Implement experimental `dep-tree` command. | 45d9dfdbfc99c59174e7c587621276b78ab7a4e9 | Jan Allersma | 2018-12-14 16:11:53 |
Implement `add` command. | bbb2544bd06f29866465d651c32ca4d6e017f5e9 | Jan Allersma | 2018-12-11 15:43:10 |
Implement `exe` command. | 1eaa36242201cf7ade5f23a14340e630c267db07 | Jan Allersma | 2018-12-11 13:23:32 |
Implement `run` and `build` commands. | 14e9e25b6a06f587c1a50829e72c829ae59a87c2 | Jan Allersma | 2018-12-10 20:57:08 |
Implement non-recursive dependency check. | 5ffd40604755d1c2dde9353c74f06a006deea33c | Jan Allersma | 2018-12-07 20:50:42 |
Restructure project. | c2d98caf7897e87284fb2891e1d4b92d14cf37e1 | Jan Allersma | 2018-12-06 16:20:46 |
Initial commit. | 4c152d55edc20ac55fd749a2b32b204134a664e3 | Jan Allersma | 2018-12-05 17:03:08 |
File | Lines added | Lines deleted |
---|---|---|
Cargo.lock | 9 | 9 |
src/backend/add.rs | 1 | 1 |
src/backend/build.rs | 1 | 1 |
src/backend/config.rs | 9 | 5 |
src/backend/delete.rs | 11 | 6 |
src/backend/dep_config.rs | 44 | 0 |
src/backend/deptree.rs | 9 | 3 |
src/backend/fetch.rs | 26 | 15 |
src/backend/filesystem.rs | 17 | 0 |
src/backend/mod.rs | 1 | 0 |
src/backend/project.rs | 2 | 2 |
File Cargo.lock changed (mode: 100644) (index 072f7aa..0679f2d) | |||
1 | [[package]] | ||
2 | name = "ambassade" | ||
3 | version = "0.1.0" | ||
4 | dependencies = [ | ||
5 | "git2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", | ||
6 | "rustyline 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", | ||
7 | "serde_json 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)", | ||
8 | ] | ||
9 | |||
1 | 10 | [[package]] | [[package]] |
2 | 11 | name = "argon2rs" | name = "argon2rs" |
3 | 12 | version = "0.2.5" | version = "0.2.5" |
... | ... | dependencies = [ | |
42 | 51 | "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", | "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", |
43 | 52 | ] | ] |
44 | 53 | ||
45 | [[package]] | ||
46 | name = "ambassade" | ||
47 | version = "0.1.0" | ||
48 | dependencies = [ | ||
49 | "git2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", | ||
50 | "rustyline 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", | ||
51 | "serde_json 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)", | ||
52 | ] | ||
53 | |||
54 | 54 | [[package]] | [[package]] |
55 | 55 | name = "bitflags" | name = "bitflags" |
56 | 56 | version = "1.0.4" | version = "1.0.4" |
File src/backend/add.rs changed (mode: 100644) (index d94694a..61efc0e) | |||
... | ... | fn update_module(key: String, value: String) -> Result<String, String> { | |
41 | 41 | None => return Err(String::from("No config file in module found.")) | None => return Err(String::from("No config file in module found.")) |
42 | 42 | } | } |
43 | 43 | ||
44 | match super::config::get_json(path.clone()) { | ||
44 | match super::config::get_json_from_dir(path.clone()) { | ||
45 | 45 | Ok(mut json) => { | Ok(mut json) => { |
46 | 46 | json["deps"]["linux"][key.clone()] = json!(value); | json["deps"]["linux"][key.clone()] = json!(value); |
47 | 47 | json["deps"]["os-x"][key.clone()] = json!(value); | json["deps"]["os-x"][key.clone()] = json!(value); |
File src/backend/build.rs changed (mode: 100644) (index be084c6..d7d87e8) | |||
... | ... | use std::env; | |
7 | 7 | pub fn build(config_file: PathBuf) -> Result<String, String> { | pub fn build(config_file: PathBuf) -> Result<String, String> { |
8 | 8 | let config; | let config; |
9 | 9 | ||
10 | match super::config::get_json(config_file) { | ||
10 | match super::config::get_json_from_dir(config_file) { | ||
11 | 11 | Ok(result) => config = result, | Ok(result) => config = result, |
12 | 12 | Err(e) => return Err(e) | Err(e) => return Err(e) |
13 | 13 | } | } |
File src/backend/config.rs changed (mode: 100644) (index 98b1644..092bee7) | |||
... | ... | pub fn create(mut path: PathBuf) -> Result<(), Error> { | |
11 | 11 | init(&path) | init(&path) |
12 | 12 | } | } |
13 | 13 | ||
14 | fn init(path: &PathBuf) -> Result<(), Error> { | ||
14 | pub fn init(path: &PathBuf) -> Result<(), Error> { | ||
15 | 15 | let content = json!({ | let content = json!({ |
16 | 16 | "build": { | "build": { |
17 | 17 | "windows": "", | "windows": "", |
... | ... | pub fn update(mut path: PathBuf, value: serde_json::Value) -> Result<(), String> | |
54 | 54 | } | } |
55 | 55 | } | } |
56 | 56 | ||
57 | fn read(path: &mut PathBuf) -> Result<String, Error> { | ||
57 | fn read(path: &PathBuf) -> Result<String, Error> { | ||
58 | 58 | let mut config = String::new(); | let mut config = String::new(); |
59 | 59 | ||
60 | path.push("ambassade.json"); | ||
61 | 60 | check(&path); | check(&path); |
62 | 61 | ||
63 | 62 | match File::open(path.to_str().unwrap()) { | match File::open(path.to_str().unwrap()) { |
... | ... | fn read(path: &mut PathBuf) -> Result<String, Error> { | |
70 | 69 | Ok(config) | Ok(config) |
71 | 70 | } | } |
72 | 71 | ||
73 | pub fn get_json(mut path: PathBuf) -> Result<serde_json::Value, String> { | ||
74 | match read(&mut path) { | ||
72 | pub fn get_json(path: &PathBuf) -> Result<serde_json::Value, String> { | ||
73 | match read(path) { | ||
75 | 74 | Ok(config) => super::dep::json(config), | Ok(config) => super::dep::json(config), |
76 | 75 | Err(e) => { | Err(e) => { |
77 | 76 | println!("Error on config file: '{}'.", path.to_str().unwrap()); | println!("Error on config file: '{}'.", path.to_str().unwrap()); |
... | ... | pub fn get_json(mut path: PathBuf) -> Result<serde_json::Value, String> { | |
84 | 83 | } | } |
85 | 84 | } | } |
86 | 85 | ||
86 | pub fn get_json_from_dir(mut path: PathBuf) -> Result<serde_json::Value, String> { | ||
87 | path.push("ambassade.json"); | ||
88 | get_json(&path) | ||
89 | } | ||
90 | |||
87 | 91 | fn check(config: &PathBuf) { | fn check(config: &PathBuf) { |
88 | 92 | if !config.is_file() { | if !config.is_file() { |
89 | 93 | let mut input = String::new(); | let mut input = String::new(); |
File src/backend/delete.rs changed (mode: 100644) (index 87818db..5af0d40) | |||
... | ... | fn dep_check_rec(tree: &Node) -> Result<Vec<Node>, String> { | |
42 | 42 | ||
43 | 43 | fn dep_check(node: &Node) -> Result<(), String> { | fn dep_check(node: &Node) -> Result<(), String> { |
44 | 44 | let mut input = String::new(); | let mut input = String::new(); |
45 | let mut config_path = PathBuf::new(); | ||
45 | let mut super_module = String::new(); | ||
46 | 46 | ||
47 | 47 | match dep_check_rec(node) { | match dep_check_rec(node) { |
48 | 48 | Ok(nodes) => { | Ok(nodes) => { |
49 | 49 | for dep in nodes { | for dep in nodes { |
50 | config_path = dep.path; | ||
50 | super_module = dep.name; | ||
51 | 51 | } | } |
52 | 52 | }, | }, |
53 | 53 | Err(e) => return Err(e) | Err(e) => return Err(e) |
... | ... | fn dep_check(node: &Node) -> Result<(), String> { | |
61 | 61 | Err(e) => return Err(e.to_string()) | Err(e) => return Err(e.to_string()) |
62 | 62 | } | } |
63 | 63 | ||
64 | if config_path == PathBuf::new() { | ||
64 | if super_module == String::new() { | ||
65 | 65 | return Ok(()); | return Ok(()); |
66 | 66 | } | } |
67 | 67 | ||
68 | rm_from_config(config_path, node.name.clone()) | ||
68 | rm_from_config(super_module, node.name.clone()) | ||
69 | 69 | } | } |
70 | 70 | ||
71 | fn rm_from_config(super_module: PathBuf, dep_name: String) -> Result<(), String> { | ||
72 | let mut json = match super::config::get_json(super_module.clone()) { | ||
71 | fn rm_from_config(super_module: String, dep_name: String) -> Result<(), String> { | ||
72 | let super_module = match super::dep_config::scan(super_module) { | ||
73 | Ok(path) => path, | ||
74 | Err(e) => return Err(e) | ||
75 | }; | ||
76 | |||
77 | let mut json = match super::config::get_json(&super_module) { | ||
73 | 78 | Ok(config) => config, | Ok(config) => config, |
74 | 79 | Err(e) => return Err(e) | Err(e) => return Err(e) |
75 | 80 | }; | }; |
File src/backend/dep_config.rs added (mode: 100644) (index 0000000..081f62e) | |||
1 | use std::path::PathBuf; | ||
2 | |||
3 | pub fn init(mut dep_name: String) -> Result<(), String> { | ||
4 | let mut config = match super::filesystem::get_dep_config_root() { | ||
5 | Ok(path) => path, | ||
6 | Err(e) => return Err(e.to_string()) | ||
7 | }; | ||
8 | |||
9 | dep_name.push_str(".json"); | ||
10 | config.push(dep_name); | ||
11 | |||
12 | match super::config::init(&config) { | ||
13 | Ok(_) => Ok(()), | ||
14 | Err(e) => Err(e.to_string()) | ||
15 | } | ||
16 | } | ||
17 | |||
18 | pub fn scan(dep_name: String) -> Result<PathBuf, String> { | ||
19 | println!("Scanning for {}..", dep_name); | ||
20 | |||
21 | let mut config_path = match super::filesystem::get_dep_config_root() { | ||
22 | Ok(path) => path, | ||
23 | Err(e) => return Err(e.to_string()) | ||
24 | }; | ||
25 | |||
26 | let mut config_name = dep_name.clone(); | ||
27 | config_name.push_str(".json"); | ||
28 | config_path.push(config_name); | ||
29 | |||
30 | if config_path.is_file() { | ||
31 | return Ok(config_path); | ||
32 | } | ||
33 | |||
34 | match super::filesystem::get_current_dep_root() { | ||
35 | Ok(mut path) => { | ||
36 | path.push(dep_name); | ||
37 | match super::config::get_json_from_dir(path.clone()) { // Inconventient, should be changed later | ||
38 | Ok(_) => Ok(path), | ||
39 | Err(e) => Err(e) | ||
40 | } | ||
41 | }, | ||
42 | Err(e) => Err(e.to_string()) | ||
43 | } | ||
44 | } |
File src/backend/deptree.rs changed (mode: 100644) (index 1c35108..7f2ce70) | |||
... | ... | impl PartialEq for Node { | |
48 | 48 | pub fn print(os: &OS, path: PathBuf) -> Result<Node, String> { | pub fn print(os: &OS, path: PathBuf) -> Result<Node, String> { |
49 | 49 | let mut deps: Vec<String> = Vec::new(); | let mut deps: Vec<String> = Vec::new(); |
50 | 50 | let mut nodes: Vec<Node> = Vec::new(); | let mut nodes: Vec<Node> = Vec::new(); |
51 | let dep_name = String::from(path.file_name().unwrap().to_str().unwrap()); | ||
51 | 52 | ||
52 | let deps_json = match super::config::get_json(path.clone()) { | ||
53 | let config_path = match super::dep_config::scan(dep_name.clone()) { | ||
54 | Ok(path) => path, | ||
55 | Err(e) => return Err(e) | ||
56 | }; | ||
57 | |||
58 | let deps_json = match super::config::get_json(&config_path) { | ||
53 | 59 | Ok(config) => config, | Ok(config) => config, |
54 | 60 | Err(e) => return Err(e) | Err(e) => return Err(e) |
55 | 61 | }; | }; |
... | ... | pub fn print(os: &OS, path: PathBuf) -> Result<Node, String> { | |
77 | 83 | } | } |
78 | 84 | ||
79 | 85 | let root = Node { | let root = Node { |
80 | name: String::from(path.file_name().unwrap().to_str().unwrap()), | ||
81 | path: path, | ||
86 | name: dep_name, | ||
87 | path: path, // What if backend::config::get_json_from_dir(root.path) gets called? | ||
82 | 88 | depends_on: nodes | depends_on: nodes |
83 | 89 | }; | }; |
84 | 90 |
File src/backend/fetch.rs changed (mode: 100644) (index 2ddfbe7..9c7fd2a) | |||
... | ... | use std::path::PathBuf; | |
6 | 6 | use std::result::Result; | use std::result::Result; |
7 | 7 | ||
8 | 8 | pub fn build(dep: PathBuf, mut command: String) -> Result<String, String> { | pub fn build(dep: PathBuf, mut command: String) -> Result<String, String> { |
9 | let dep_name = String::from(dep.file_name().unwrap().to_str().unwrap()); | ||
10 | |||
9 | 11 | if command == String::new() { | if command == String::new() { |
10 | match set_command(&dep, true) { | ||
12 | match set_command(&dep_name, true) { | ||
11 | 13 | Some(cmd) => command = cmd, | Some(cmd) => command = cmd, |
12 | 14 | None => return Err(String::from("Fetching failed: no appropriate command set.")) | None => return Err(String::from("Fetching failed: no appropriate command set.")) |
13 | 15 | } | } |
14 | 16 | } | } |
15 | fetch(dep, command) | ||
17 | fetch(dep_name, &dep, command) | ||
16 | 18 | } | } |
17 | 19 | ||
18 | 20 | pub fn run(dep: PathBuf, mut command: String) -> Result<String, String> { | pub fn run(dep: PathBuf, mut command: String) -> Result<String, String> { |
21 | let dep_name = String::from(dep.file_name().unwrap().to_str().unwrap()); | ||
22 | |||
19 | 23 | if command == String::new() { | if command == String::new() { |
20 | match set_command(&dep, false) { | ||
24 | match set_command(&dep_name, false) { | ||
21 | 25 | Some(cmd) => command = cmd, | Some(cmd) => command = cmd, |
22 | 26 | None => return Err(String::from("Fetching failed: no appropriate command set.")) | None => return Err(String::from("Fetching failed: no appropriate command set.")) |
23 | 27 | } | } |
24 | 28 | } | } |
25 | fetch(dep, command) | ||
29 | fetch(dep_name, &dep, command) | ||
26 | 30 | } | } |
27 | 31 | ||
28 | fn fetch(dep: PathBuf, command: String) -> Result<String, String> { | ||
32 | fn fetch(dep_name: String, path: &PathBuf, command: String) -> Result<String, String> { | ||
29 | 33 | let mut args: Vec<&str> = command.split(' ').collect(); | let mut args: Vec<&str> = command.split(' ').collect(); |
30 | 34 | let command = args.remove(0); | let command = args.remove(0); |
31 | 35 | let out = Command::new(command) | let out = Command::new(command) |
32 | .current_dir(&dep) | ||
36 | .current_dir(path) | ||
33 | 37 | .args(args) | .args(args) |
34 | 38 | .stdin(Stdio::inherit()) | .stdin(Stdio::inherit()) |
35 | 39 | .stdout(Stdio::inherit()) | .stdout(Stdio::inherit()) |
... | ... | fn fetch(dep: PathBuf, command: String) -> Result<String, String> { | |
43 | 47 | } | } |
44 | 48 | }, | }, |
45 | 49 | Err(e) => { | Err(e) => { |
46 | let mut config_file = dep.clone(); | ||
47 | config_file.push("ambassade.json"); | ||
50 | let config_path = match super::dep_config::scan(dep_name) { | ||
51 | Ok(p) => p, | ||
52 | Err(e) => return Err(e) | ||
53 | }; | ||
48 | 54 | ||
49 | 55 | let mut error = String::from("Fetching failed: command '"); | let mut error = String::from("Fetching failed: command '"); |
50 | 56 | error.push_str(command); | error.push_str(command); |
... | ... | fn fetch(dep: PathBuf, command: String) -> Result<String, String> { | |
52 | 58 | error.push_str(&e.to_string()); | error.push_str(&e.to_string()); |
53 | 59 | error.push_str("\n\nConsider changing the above command in the '"); | error.push_str("\n\nConsider changing the above command in the '"); |
54 | 60 | ||
55 | match config_file.to_str() { | ||
56 | Some(path) => error.push_str(path), | ||
57 | None => error.push_str("ambassade.json") | ||
61 | match config_path.to_str() { | ||
62 | Some(p) => error.push_str(p), | ||
63 | None => error.push_str("configuration") | ||
58 | 64 | } | } |
59 | 65 | ||
60 | 66 | error.push_str("' file."); | error.push_str("' file."); |
... | ... | fn fetch(dep: PathBuf, command: String) -> Result<String, String> { | |
63 | 69 | } | } |
64 | 70 | } | } |
65 | 71 | ||
66 | fn set_command(dep: &PathBuf, build_cmd: bool) -> Option<String> { | ||
72 | fn set_command(dep: &String, build_cmd: bool) -> Option<String> { | ||
67 | 73 | let mut editor = rustyline::Editor::<()>::new(); | let mut editor = rustyline::Editor::<()>::new(); |
68 | 74 | ||
69 | 75 | let msg = match build_cmd { | let msg = match build_cmd { |
... | ... | fn set_command(dep: &PathBuf, build_cmd: bool) -> Option<String> { | |
94 | 100 | } | } |
95 | 101 | } | } |
96 | 102 | ||
97 | fn update_module(root: &PathBuf, key: String, value: String) -> Result<String, String> { | ||
103 | fn update_module(dep_name: &String, key: String, value: String) -> Result<String, String> { | ||
98 | 104 | let config: serde_json::Value; | let config: serde_json::Value; |
99 | 105 | ||
100 | match super::config::get_json(root.clone()) { | ||
106 | let path = match super::dep_config::scan(dep_name.clone()) { | ||
107 | Ok(path) => path, | ||
108 | Err(e) => return Err(e) | ||
109 | }; | ||
110 | |||
111 | match super::config::get_json(&path) { | ||
101 | 112 | Ok(mut json) => { | Ok(mut json) => { |
102 | 113 | json[key.clone()]["linux"] = json!(value); | json[key.clone()]["linux"] = json!(value); |
103 | 114 | json[key.clone()]["os-x"] = json!(value); | json[key.clone()]["os-x"] = json!(value); |
... | ... | fn update_module(root: &PathBuf, key: String, value: String) -> Result<String, S | |
107 | 118 | Err(e) => return Err(e) | Err(e) => return Err(e) |
108 | 119 | } | } |
109 | 120 | ||
110 | match super::config::update(root.clone(), config) { | ||
121 | match super::config::update(path, config) { | ||
111 | 122 | Ok(_) => Ok(String::from("Command updated!")), | Ok(_) => Ok(String::from("Command updated!")), |
112 | 123 | Err(e) => Err(e) | Err(e) => Err(e) |
113 | 124 | } | } |
File src/backend/filesystem.rs changed (mode: 100644) (index 3467053..5190c5f) | |||
... | ... | pub fn get_dep_root(from_dir: path::PathBuf) -> Result<path::PathBuf> { | |
66 | 66 | None => Err(Error::new(ErrorKind::NotFound, "No project file found. Aborted.")) | None => Err(Error::new(ErrorKind::NotFound, "No project file found. Aborted.")) |
67 | 67 | } | } |
68 | 68 | } | } |
69 | |||
70 | pub fn get_dep_config_root() -> Result<path::PathBuf> { | ||
71 | match get_current_project_root() { | ||
72 | Some(mut path) => { | ||
73 | path.push("dep_config"); | ||
74 | if !path.exists() { | ||
75 | println!("\t No dep_config folder found. Creating folder.."); | ||
76 | match fs::create_dir(path.clone()) { | ||
77 | Ok(_) => println!("\tCreated dir {}.", path.clone().to_str().unwrap()), | ||
78 | Err(e) => return Err(e) | ||
79 | } | ||
80 | } | ||
81 | Ok(path) | ||
82 | }, | ||
83 | None => Err(Error::new(ErrorKind::NotFound, "No project file found. Aborted.")) | ||
84 | } | ||
85 | } |
File src/backend/mod.rs changed (mode: 100644) (index 7bdad7e..e7b9123) | |||
1 | 1 | pub mod add; | pub mod add; |
2 | 2 | pub mod delete; | pub mod delete; |
3 | 3 | pub mod config; | pub mod config; |
4 | pub mod dep_config; | ||
4 | 5 | pub mod deptree; | pub mod deptree; |
5 | 6 | pub mod project; | pub mod project; |
6 | 7 | pub mod filesystem; | pub mod filesystem; |
File src/backend/project.rs changed (mode: 100644) (index d4affa5..a42a6b6) | |||
... | ... | pub fn exe<I>(args: &mut I) -> Result<String, String> where I: Iterator<Item=Str | |
41 | 41 | None => return Err(String::from("not in a project (sub)directory.")) | None => return Err(String::from("not in a project (sub)directory.")) |
42 | 42 | } | } |
43 | 43 | ||
44 | match super::config::get_json(output_dir) { | ||
44 | match super::config::get_json_from_dir(output_dir) { | ||
45 | 45 | Ok(config) => { | Ok(config) => { |
46 | 46 | if cfg!(target_os = "linux") { | if cfg!(target_os = "linux") { |
47 | 47 | match config["run"]["linux"].as_str() { | match config["run"]["linux"].as_str() { |
... | ... | pub fn add(args: &Vec<String>) -> Result<String, String> { | |
113 | 113 | Err(e) => return Err(e) | Err(e) => return Err(e) |
114 | 114 | } | } |
115 | 115 | ||
116 | match super::config::get_json(dir) { | ||
116 | match super::config::get_json_from_dir(dir) { | ||
117 | 117 | Ok(json) => { | Ok(json) => { |
118 | 118 | super::dep::check(json) | super::dep::check(json) |
119 | 119 | }, | }, |