Skip to content

Commit

Permalink
Added info command
Browse files Browse the repository at this point in the history
  • Loading branch information
mqxf committed Sep 24, 2022
1 parent 5f6668b commit e2d294e
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .mvc/scripts.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
{
"name": "build",
"script": "bWFrZQo=",
"script": "bWFrZQpzdWRvIG12IGJpbi9tdmMgL3Vzci9sb2NhbC9iaW4vLgo=",
"type": "sh",
"args": 0
}
Expand Down
11 changes: 11 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { printMainHelpMenu } from "./help.ts";
import { build, commit, other, push } from "./script/basic.ts";
import { runScript } from "./script/run.ts";
import { editScript } from "./script/script.ts";
import { checkDir, info } from "./utils.ts";

async function main(args: string[]) {
if (args.length < 1) {
Expand All @@ -20,22 +21,32 @@ async function main(args: string[]) {
case "setup":
await setupProject(args);
break;
case "info":
checkDir();
info();
break;
case "run":
checkDir();
await runScript(args);
break;
case "script":
checkDir();
await editScript(args);
break;
case "push":
checkDir();
await push(args);
break;
case "commit":
checkDir();
await commit(args);
break;
case "build":
checkDir();
await build(args);
break;
default:
checkDir();
await other(args);
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/script/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,6 @@ export async function other(args: string[]) {
}
});
if (!found) {
console.log(`Could not find the '${args[0]}' script, please create one using 'mvc script'.`);
console.log(`Unkown subcommand '${args[0]}'.`);
}
}
31 changes: 30 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,35 @@
import { encode, decode } from "https://deno.land/[email protected]/encoding/base64.ts"
import { Confirm, Input } from "https://deno.land/x/[email protected]/prompt/mod.ts";
import { getScripts, writeScripts } from "./file.ts";
import { ConfigFile, getConfig, getScripts, ScriptsFile, writeScripts } from "./file.ts";

export async function info() {
const config = await getConfig();
console.log(`
Project '${config.name}' by '${config.author}'
Using mvc command line build tool
Uses the ${config.language} licence
Git is ${config.git ? '' : 'not '}configured. ${(!config.git || config.gitLink == '') ? '' : `\nExternal git repository is ${config.gitLink}`}
`)
}

export async function checkDir() {
let config: ConfigFile ;
let scripts: ScriptsFile;
try {
config = await getConfig();
scripts = await getScripts();
}
catch (_err) {
console.log("No mvc project was configured at this location");
await Deno.exit(1);
return;
}
if (config == null || scripts == null) {
console.log("No mvc project was configured at this location");
await Deno.exit(1);
return;
}
}

export async function shs(cmds: string[], wait = false) {
for (let i = 0; i < cmds.length; i++) {
Expand Down

0 comments on commit e2d294e

Please sign in to comment.