List of commits:
Subject Hash Author Date (UTC)
Add feature: initialize hidden dependencies. fc99666c48da1653b3097a0251d8219bc49886cb Jan Allersma 2019-01-12 15:52:45
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
Commit fc99666c48da1653b3097a0251d8219bc49886cb - Add feature: initialize hidden dependencies.
Author: Jan Allersma
Author date (UTC): 2019-01-12 15:52
Committer name: Jan Allersma
Committer date (UTC): 2019-01-12 19:12
Parent(s): 482bad08f949eaedbd61e2cb7c53870271d47997
Signing key:
Tree: 26fa8b4930df7b62abc90e19cc4a03fbe7da3014
File Lines added Lines deleted
README.md 2 0
src/backend/add.rs 5 3
src/backend/build.rs 24 17
src/backend/config.rs 1 3
src/backend/dep_config.rs 11 0
src/backend/fetch.rs 1 1
src/backend/filesystem.rs 24 1
src/backend/git/ignore.rs 2 0
src/backend/project.rs 22 12
src/parser.rs 1 6
File README.md changed (mode: 100644) (index e1dd235..5b5fa7c)
3 3 ## Notes ## Notes
4 4
5 5 `backend::fetch::update_module()` kan wellicht met `backend::add::update_module()` samengevoegd worden. `backend::fetch::update_module()` kan wellicht met `backend::add::update_module()` samengevoegd worden.
6
7 Missing feature in `backend::git::ignore` (see [related file](src/backend/git/ignore.rs)).
File src/backend/add.rs changed (mode: 100644) (index 61efc0e..2713beb)
... ... pub fn add(args: &Vec<String>) -> Result<String, String> {
33 33 } }
34 34
35 35 fn update_module(key: String, value: String) -> Result<String, String> { fn update_module(key: String, value: String) -> Result<String, String> {
36 let path: PathBuf;
36 let mut path: PathBuf;
37 37 let config: serde_json::Value; let config: serde_json::Value;
38 38
39 39 match super::filesystem::get_current_module_root() { match super::filesystem::get_current_module_root() {
 
... ... 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_from_dir(path.clone()) {
44 path.push("ambassade.json");
45
46 match super::config::get_json(&path) {
45 47 Ok(mut json) => { Ok(mut json) => {
46 48 json["deps"]["linux"][key.clone()] = json!(value); json["deps"]["linux"][key.clone()] = json!(value);
47 49 json["deps"]["os-x"][key.clone()] = json!(value); json["deps"]["os-x"][key.clone()] = json!(value);
 
... ... fn update_module(key: String, value: String) -> Result<String, String> {
51 53 Err(e) => return Err(e) Err(e) => return Err(e)
52 54 } }
53 55
54 match super::config::update(path, config) {
56 match super::config::update(&path, config) {
55 57 Ok(_) => Ok(String::from("Dependency added!")), Ok(_) => Ok(String::from("Dependency added!")),
56 58 Err(e) => Err(e) Err(e) => Err(e)
57 59 } }
File src/backend/build.rs changed (mode: 100644) (index d7d87e8..41102be)
... ... extern crate serde_json;
2 2
3 3 use std::result::Result; use std::result::Result;
4 4 use std::path::PathBuf; use std::path::PathBuf;
5 use std::env;
6 5
7 pub fn build(config_file: PathBuf) -> Result<String, String> {
8 let config;
6 pub fn build(dep_name: String) -> Result<String, String> {
7 let dep_path = match super::filesystem::search_current_module_root(dep_name.clone()) {
8 Ok(path) => path,
9 Err(e) => return Err(e.to_string())
10 };
9 11
10 match super::config::get_json_from_dir(config_file) {
11 Ok(result) => config = result,
12 let config_path = match super::dep_config::scan(dep_name) {
13 Ok(path) => path,
12 14 Err(e) => return Err(e) Err(e) => return Err(e)
13 }
15 };
16
17 let config = match super::config::get_json(&config_path) {
18 Ok(json) => json,
19 Err(e) => return Err(e)
20 };
14 21
15 22 match super::dep::check(config.clone()) { match super::dep::check(config.clone()) {
16 23 Ok(result) => println!("{}", result), Ok(result) => println!("{}", result),
17 24 Err(e) => return Err(e) Err(e) => return Err(e)
18 25 } }
19 26
20 match build_module(config) {
27 match build_module(dep_path, config) {
21 28 Ok(result) => println!("{}", result), Ok(result) => println!("{}", result),
22 29 Err(e) => return Err(e) Err(e) => return Err(e)
23 30 } }
 
... ... pub fn build_rec(config_file: PathBuf) -> Result<String, String> {
45 52 } }
46 53
47 54 println!("Building current project '{}'..", &dep_tree.name); println!("Building current project '{}'..", &dep_tree.name);
48 match build(dep_tree.path) {
55 match build(dep_tree.name) {
49 56 Ok(result) => println!("{}", result), Ok(result) => println!("{}", result),
50 57 Err(e) => return Err(e) Err(e) => return Err(e)
51 58 } }
 
... ... pub fn build_rec(config_file: PathBuf) -> Result<String, String> {
54 61 } }
55 62
56 63 #[cfg(target_os="linux")] #[cfg(target_os="linux")]
57 fn build_module(config: serde_json::Value) -> Result<String, String> {
64 fn build_module(config_path: PathBuf, config_value: serde_json::Value) -> Result<String, String> {
58 65 println!("Building module.."); println!("Building module..");
59 66
60 let build_cmd = &config["build"]["linux"];
67 let build_cmd = &config_value["build"]["linux"];
61 68
62 69 if !build_cmd.is_string() { if !build_cmd.is_string() {
63 70 return Err(String::from("ambassade.json: 'build->linux' should be a string.")); return Err(String::from("ambassade.json: 'build->linux' should be a string."));
64 71 } }
65 72
66 super::fetch::build(env::current_dir().unwrap(), String::from(build_cmd.as_str().unwrap()))
73 super::fetch::build(config_path, String::from(build_cmd.as_str().unwrap()))
67 74 } }
68 75
69 76 #[cfg(target_os="macos")] #[cfg(target_os="macos")]
70 fn build_module(config: serde_json::Value) -> Result<String, String> {
77 fn build_module(config_path: PathBuf, config_value: serde_json::Value) -> Result<String, String> {
71 78 println!("Building module.."); println!("Building module..");
72 79
73 let build_cmd = &config["build"]["os-x"];
80 let build_cmd = &config_value["build"]["os-x"];
74 81
75 82 if !build_cmd.is_string() { if !build_cmd.is_string() {
76 83 return Err(String::from("ambassade.json: 'build->os-x' should be a string.")); return Err(String::from("ambassade.json: 'build->os-x' should be a string."));
77 84 } }
78 85
79 super::fetch::fetch(env::get_current_dir().unwrap(), String::from(build_cmd.as_str().unwrap()))
86 super::fetch::build(config_path, String::from(build_cmd.as_str().unwrap()))
80 87 } }
81 88
82 89 #[cfg(target_os="windows")] #[cfg(target_os="windows")]
83 fn build_module(config: serde_json::Value) -> Result<String, String> {
90 fn build_module(config_path: PathBuf, config_value: serde_json::Value) -> Result<String, String> {
84 91 println!("Building module.."); println!("Building module..");
85 92
86 let build_cmd = &config["build"]["windows"];
93 let build_cmd = &config_value["build"]["windows"];
87 94
88 95 if !build_cmd.is_string() { if !build_cmd.is_string() {
89 96 return Err(String::from("ambassade.json: 'build->windows' should be a string.")); return Err(String::from("ambassade.json: 'build->windows' should be a string."));
90 97 } }
91 98
92 super::fetch::fetch(env::get_current_dir().unwrap(), String::from(build_cmd.as_str().unwrap()))
99 super::fetch::build(config_path, String::from(build_cmd.as_str().unwrap()))
93 100 } }
File src/backend/config.rs changed (mode: 100644) (index 092bee7..d301561)
... ... pub fn init(path: &PathBuf) -> Result<(), Error> {
40 40 Ok(()) Ok(())
41 41 } }
42 42
43 pub fn update(mut path: PathBuf, value: serde_json::Value) -> Result<(), String> {
44 path.push("ambassade.json");
45
43 pub fn update(path: &PathBuf, value: serde_json::Value) -> Result<(), String> {
46 44 match File::create(path) { match File::create(path) {
47 45 Ok(mut file) => { Ok(mut file) => {
48 46 match file.write_all(serde_json::to_string_pretty(&value).unwrap().as_bytes()) { match file.write_all(serde_json::to_string_pretty(&value).unwrap().as_bytes()) {
File src/backend/dep_config.rs changed (mode: 100644) (index 081f62e..23b9f70)
... ... pub fn scan(dep_name: String) -> Result<PathBuf, String> {
31 31 return Ok(config_path); return Ok(config_path);
32 32 } }
33 33
34 match super::filesystem::get_current_project_root() {
35 Some(mut path) => {
36 if String::from(path.file_name().unwrap().to_str().unwrap()) == dep_name {
37 println!("Project name equals dep name. Taking project's configfile...");
38 path.push("ambassade.json");
39 return Ok(path);
40 }
41 },
42 None => println!("Couldn't find current project root. Skipped in scan.")
43 }
44
34 45 match super::filesystem::get_current_dep_root() { match super::filesystem::get_current_dep_root() {
35 46 Ok(mut path) => { Ok(mut path) => {
36 47 path.push(dep_name); path.push(dep_name);
File src/backend/fetch.rs changed (mode: 100644) (index 9c7fd2a..6ee12ad)
... ... fn update_module(dep_name: &String, key: String, value: String) -> Result<String
118 118 Err(e) => return Err(e) Err(e) => return Err(e)
119 119 } }
120 120
121 match super::config::update(path, config) {
121 match super::config::update(&path, config) {
122 122 Ok(_) => Ok(String::from("Command updated!")), Ok(_) => Ok(String::from("Command updated!")),
123 123 Err(e) => Err(e) Err(e) => Err(e)
124 124 } }
File src/backend/filesystem.rs changed (mode: 100644) (index 5190c5f..e3e8889)
1 use std::{path, env, fs};
1 use std::{path, env, fs, result};
2 2 use std::io::{Result, Error, ErrorKind}; use std::io::{Result, Error, ErrorKind};
3 3
4 4 fn get_root(mut path: path::PathBuf) -> Option<path::PathBuf> { fn get_root(mut path: path::PathBuf) -> Option<path::PathBuf> {
 
... ... pub fn get_dep_root(from_dir: path::PathBuf) -> Result<path::PathBuf> {
67 67 } }
68 68 } }
69 69
70 pub fn search_current_module_root(dep_name: String) -> result::Result<path::PathBuf, String> {
71 search_module_root(dep_name, env::current_dir().unwrap())
72 }
73
74 pub fn search_module_root(dep_name: String, from_dir: path::PathBuf) -> result::Result<path::PathBuf, String> {
75 let project_path = match get_project_root(from_dir.clone()) {
76 Some(path) => path,
77 None => return Err(String::from("No project folder found!"))
78 };
79
80 if dep_name == String::from(project_path.file_name().unwrap().to_str().unwrap()) {
81 return Ok(project_path);
82 }
83
84 match get_dep_root(from_dir) {
85 Ok(mut dir) => {
86 dir.push(dep_name);
87 Ok(dir)
88 },
89 Err(e) => Err(e.to_string())
90 }
91 }
92
70 93 pub fn get_dep_config_root() -> Result<path::PathBuf> { pub fn get_dep_config_root() -> Result<path::PathBuf> {
71 94 match get_current_project_root() { match get_current_project_root() {
72 95 Some(mut path) => { Some(mut path) => {
File src/backend/git/ignore.rs changed (mode: 100644) (index 8f135f3..698ac0e)
... ... pub fn add(path: &mut PathBuf, item: &mut String) -> Result<(), String> {
30 30 } }
31 31 } }
32 32 } }
33
34 // pub fn init(); // Moet evt .gitignore aanmaken en de dep folder in de .gitignore plaatsen.
File src/backend/project.rs changed (mode: 100644) (index a42a6b6..22b03b2)
... ... pub fn build<I>(args: &mut I) -> Result<String, String> where I: Iterator<Item=S
19 19 match args.next() { match args.next() {
20 20 Some(ref module) if module.as_str() == "--module" => { Some(ref module) if module.as_str() == "--module" => {
21 21 match super::filesystem::get_current_module_root() { match super::filesystem::get_current_module_root() {
22 Some(dir) => super::build::build(dir),
22 Some(dir) => {
23 let dep_name = String::from(dir.file_name().unwrap().to_str().unwrap());
24 super::build::build(dep_name)
25 },
23 26 None => Err(String::from("not in a project (sub)directory.")) None => Err(String::from("not in a project (sub)directory."))
24 27 } }
25 28 }, },
 
... ... pub fn delete<I>(path: &mut I) -> Result<String, String> where I: Iterator<Item=
96 99 } }
97 100
98 101 pub fn add(args: &Vec<String>) -> Result<String, String> { pub fn add(args: &Vec<String>) -> Result<String, String> {
99 let mut path: String = match args.get(0) {
102 let mut dep: String = match args.get(0) {
100 103 Some(arg) => arg.clone(), Some(arg) => arg.clone(),
101 None => return Err(String::from("Missing path as argument."))
104 None => return Err(String::from("Missing dependency name as argument."))
102 105 }; };
103 106
104 107 match super::filesystem::get_current_module_root() { match super::filesystem::get_current_module_root() {
105 108 Some(dir) => { Some(dir) => {
106 match super::git::ignore::add(&mut dir.clone(), &mut path) {
109 match super::git::ignore::add(&mut dir.clone(), &mut dep) {
107 110 Ok(_) => {}, Ok(_) => {},
108 111 Err(e) => return Err(e) Err(e) => return Err(e)
109 112 } }
 
... ... pub fn add(args: &Vec<String>) -> Result<String, String> {
124 127 } }
125 128 } }
126 129
127 pub fn ignore(args: &Vec<String>) -> Result<(), String> {
128 let mut entry: String = args.get(0).unwrap().clone();
130 pub fn hide(args: &Vec<String>) -> Result<String, String> {
131 match add(args) {
132 Ok(msg) => println!("{}", msg),
133 Err(e) => return Err(e)
134 }
129 135
130 match super::filesystem::get_current_dep_root() {
131 Ok(mut dir) => {
132 dir.push(&entry);
133 super::git::ignore::add(&mut dir, &mut entry) // entry moet "ambassade.json" worden.
134 },
135 Err(e) => Err(e.to_string())
136 let dep: String = match args.get(0) {
137 Some(arg) => arg.clone(),
138 None => return Err(String::from("Missing dep name."))
139 };
140
141 match super::dep_config::init(dep.clone()) {
142 Ok(_) => println!("Created '{}.json' in 'dep_config' folder.", dep),
143 Err(e) => return Err(e)
136 144 } }
145
146 Ok(String::from("dependency successfully hidden!"))
137 147 } }
138 148
139 149 pub fn dep_tree<I>(args: &mut I) -> Result<deptree::Node, String> where I: Iterator<Item=String> { pub fn dep_tree<I>(args: &mut I) -> Result<deptree::Node, String> where I: Iterator<Item=String> {
File src/parser.rs changed (mode: 100644) (index 9d1a6ea..2415cd8)
... ... fn parse<I>(args: &mut I, open_shell: bool) -> bool where I: Iterator<Item=Strin
50 50 } }
51 51 else if argument == "hide" { else if argument == "hide" {
52 52 let args: Vec<String> = args.collect(); let args: Vec<String> = args.collect();
53 match backend::project::add(&args) {
53 match backend::project::hide(&args) {
54 54 Ok(msg) => println!("{}", msg), Ok(msg) => println!("{}", msg),
55 Err(e) => println!("Could not add dependency: {}", e)
56 }
57
58 match backend::project::ignore(&args) {
59 Ok(_) => println!("DONE! Dependency hidden."),
60 55 Err(e) => println!("Could not hide dependency: {}", e) Err(e) => println!("Could not hide dependency: {}", e)
61 56 } }
62 57 } }
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/kapstok/NHL-Beheer

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/kapstok/NHL-Beheer

Clone this repository using git:
git clone git://git.rocketgit.com/user/kapstok/NHL-Beheer

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main