Добавлена проверка на наличие установленного git в системе
This commit is contained in:
parent
a7676d5886
commit
cc85cdec78
2 changed files with 13 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
|||
import snag;
|
||||
import commandr;
|
||||
import std.file;
|
||||
import std.stdio : writeln;
|
||||
|
||||
import core.stdc.stdlib : EXIT_SUCCESS, EXIT_FAILURE;
|
||||
|
||||
|
@ -8,6 +9,11 @@ private string programName = "snag";
|
|||
|
||||
int main(string[] args)
|
||||
{
|
||||
if (!checkGit()) {
|
||||
"Using snag requires Git to be installed".writeln;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
auto argumets = new Program(programName, snagVersion)
|
||||
.add(new Command("init", "Initializing the repository for storing snapshots"))
|
||||
.add(new Command("status", "Checking the status of tracked files"))
|
||||
|
@ -83,7 +89,7 @@ int main(string[] args)
|
|||
}
|
||||
|
||||
auto snag = new Snag(config);
|
||||
import std.stdio;
|
||||
|
||||
try {
|
||||
argumets
|
||||
.on("init", init =>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
module snag.lib.lib;
|
||||
|
||||
import std.regex;
|
||||
import std.process;
|
||||
|
||||
bool isValidHash(string hash) {
|
||||
auto hashPattern = ctRegex!r"^[a-fA-F0-9]{7}$";
|
||||
|
@ -11,3 +12,8 @@ bool isValidEmail(string email) {
|
|||
auto emailPattern = ctRegex!r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$";
|
||||
return !matchFirst(email, emailPattern).empty;
|
||||
}
|
||||
|
||||
bool checkGit() {
|
||||
auto result = execute(["which", "git"]);
|
||||
return !result.status;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue