List of commits:
Subject Hash Author Date (UTC)
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 e81d57882036a6475718b0653169c609d23b1c30 - Resolve missing/erroneous build/run commands.
Author: Jan Allersma
Author date (UTC): 2018-12-25 13:06
Committer name: Jan Allersma
Committer date (UTC): 2018-12-25 13:06
Parent(s): ab188603dda062de4b2ea76c5bc1d2d41d98b8c2
Signing key:
Tree: f9d29f24a5aebe03e4c7a0c632290cff78b0b9e5
File Lines added Lines deleted
README.md 4 0
src/backend/build.rs 1 1
src/backend/config.rs 6 7
src/backend/dep.rs 1 1
src/backend/fetch.rs 107 7
src/backend/project.rs 1 14
File README.md changed (mode: 100644) (index 3f087ab..c04e7ca)
1 1 # Beheer # Beheer
2
3 ## Notes
4
5 `backend::fetch::update_module()` kan wellicht met `backend::add::update_module()` samengevoegd worden.
File src/backend/build.rs changed (mode: 100644) (index 7231f73..2db696b)
... ... fn build_module(config: serde_json::Value) -> Result<String, String> {
63 63 return Err(String::from("beheer.json: 'build->linux' should be a string.")); return Err(String::from("beheer.json: 'build->linux' should be a string."));
64 64 } }
65 65
66 super::fetch::fetch(env::current_dir().unwrap(), String::from(build_cmd.as_str().unwrap()))
66 super::fetch::build(env::current_dir().unwrap(), String::from(build_cmd.as_str().unwrap()))
67 67 } }
68 68
69 69 #[cfg(target_os="macos")] #[cfg(target_os="macos")]
File src/backend/config.rs changed (mode: 100644) (index e362119..495c65e)
... ... use std::result::Result;
7 7
8 8 pub fn create(mut path: PathBuf) -> Result<(), Error> { pub fn create(mut path: PathBuf) -> Result<(), Error> {
9 9 let content = json!({ let content = json!({
10 "version": 0.1,
11 10 "build": { "build": {
12 "windows": "echo \"No build config set.\"",
13 "os-x": "echo \"No build config set.\"",
14 "linux": "echo \"No build config set.\""
11 "windows": "",
12 "os-x": "",
13 "linux": ""
15 14 }, },
16 15 "run": { "run": {
17 "windows": "echo \"No run config set.\"",
18 "os-x": "echo \"No run config set.\"",
19 "linux": "echo \"No run config set.\""
16 "windows": "",
17 "os-x": "",
18 "linux": ""
20 19 } }
21 20 }); });
22 21
File src/backend/dep.rs changed (mode: 100644) (index 21b27f8..6f7d34b)
... ... fn dir_check(dependency: String, command: String) -> Result<String, String> {
195 195 dep_dir.push(dependency); dep_dir.push(dependency);
196 196 if !dep_dir.exists() { if !dep_dir.exists() {
197 197 dep_dir.pop(); dep_dir.pop();
198 return super::fetch::fetch(dep_dir, command);
198 return super::fetch::build(dep_dir, command);
199 199 } }
200 200 Ok(String::from("Dependency found.")) Ok(String::from("Dependency found."))
201 201 }, },
File src/backend/fetch.rs changed (mode: 100644) (index 2ef99f1..e98a1f3)
1 use std::process::Command;
2 use std::path;
1 extern crate rustyline;
2 extern crate serde_json;
3
4 use std::process::{Command, Stdio};
5 use std::path::PathBuf;
3 6 use std::result::Result; use std::result::Result;
4 7
5 pub fn fetch(dep: path::PathBuf, command: String) -> Result<String, String> {
8 pub fn build(dep: PathBuf, mut command: String) -> Result<String, String> {
9 if command == String::new() {
10 match set_command(&dep, true) {
11 Some(cmd) => command = cmd,
12 None => return Err(String::from("Fetching failed: no appropriate command set."))
13 }
14 }
15 fetch(dep, command)
16 }
17
18 pub fn run(dep: PathBuf, mut command: String) -> Result<String, String> {
19 if command == String::new() {
20 match set_command(&dep, false) {
21 Some(cmd) => command = cmd,
22 None => return Err(String::from("Fetching failed: no appropriate command set."))
23 }
24 }
25 fetch(dep, command)
26 }
27
28 fn fetch(dep: PathBuf, command: String) -> Result<String, String> {
6 29 let mut args: Vec<&str> = command.split(' ').collect(); let mut args: Vec<&str> = command.split(' ').collect();
7 30 let command = args.remove(0); let command = args.remove(0);
8 let out = Command::new(command).current_dir(dep).args(args).output().expect("");
31 let out = Command::new(command)
32 .current_dir(&dep)
33 .args(args)
34 .stdin(Stdio::inherit())
35 .stdout(Stdio::inherit())
36 .output();
37
38 match out {
39 Ok(response) => {
40 match response.status.success() {
41 true => Ok(String::from_utf8_lossy(&response.stdout).to_string()),
42 false => Err(String::from_utf8_lossy(&response.stderr).to_string())
43 }
44 },
45 Err(e) => {
46 let mut config_file = dep.clone();
47 config_file.push("beheer.json");
48
49 let mut error = String::from("Fetching failed: command '");
50 error.push_str(command);
51 error.push_str("' invalid. Details: ");
52 error.push_str(&e.to_string());
53 error.push_str("\n\nConsider changing the above command in the '");
54
55 match config_file.to_str() {
56 Some(path) => error.push_str(path),
57 None => error.push_str("beheer.json")
58 }
59
60 error.push_str("' file.");
61 Err(error)
62 }
63 }
64 }
65
66 fn set_command(dep: &PathBuf, build_cmd: bool) -> Option<String> {
67 let mut editor = rustyline::Editor::<()>::new();
68
69 let msg = match build_cmd {
70 true => "No build command found. Please enter new command: ",
71 false => "No run command found. Please enter new command: "
72 };
73
74 let cmd = match editor.readline(msg) {
75 Ok(ref input) if input == &String::new() => return None,
76 Err(_) => return None,
77 Ok(input) => input,
78 };
79
80 let result = match build_cmd {
81 true => update_module(dep, String::from("build"), cmd.clone()),
82 false => update_module(dep, String::from("run"), cmd.clone())
83 };
84
85 match result {
86 Ok(response) => {
87 println!("{}", response);
88 Some(cmd)
89 },
90 Err(e) => {
91 println!("{}", e);
92 None
93 }
94 }
95 }
96
97 fn update_module(root: &PathBuf, key: String, value: String) -> Result<String, String> {
98 let config: serde_json::Value;
99
100 match super::config::get_json(root.clone()) {
101 Ok(mut json) => {
102 json[key.clone()]["linux"] = json!(value);
103 json[key.clone()]["os-x"] = json!(value);
104 json[key]["windows"] = json!(value);
105 config = json.clone();
106 },
107 Err(e) => return Err(e)
108 }
9 109
10 match out.status.success() {
11 true => Ok(String::from_utf8_lossy(&out.stdout).to_string()),
12 false => Err(String::from_utf8_lossy(&out.stderr).to_string())
110 match super::config::update(root.clone(), config) {
111 Ok(_) => Ok(String::from("Command updated!")),
112 Err(e) => Err(e)
13 113 } }
14 114 } }
File src/backend/project.rs changed (mode: 100644) (index c13406c..be666ca)
... ... pub fn exe<I>(args: &mut I) -> Result<String, String> where I: Iterator<Item=Str
67 67 } }
68 68
69 69 println!("Running project.."); println!("Running project..");
70
71 let mut arguments: Vec<&str> = args.split(' ').collect();
72 let command = arguments.remove(0);
73 let out = Command::new(command)
74 .args(arguments)
75 .stdin(Stdio::inherit())
76 .stdout(Stdio::inherit())
77 .output()
78 .expect("");
79
80 match out.status.success() {
81 true => Ok(String::from_utf8_lossy(&out.stdout).to_string()),
82 false => Err(String::from_utf8_lossy(&out.stderr).to_string())
83 }
70 super::fetch::run(env::current_dir().unwrap(), args)
84 71 } }
85 72
86 73 pub fn run<I>(args: &mut I) -> Result<String, String> where I: Iterator<Item=String> { pub fn run<I>(args: &mut I) -> Result<String, String> where I: Iterator<Item=String> {
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