Making some changes ...
This commit is contained in:
parent
d54dc7c799
commit
298df3fca3
3 changed files with 53 additions and 11 deletions
|
@ -82,7 +82,7 @@ abstract class GitClient {
|
|||
public abstract function add($path) : string;
|
||||
|
||||
|
||||
public abstract function diff($path) : string;
|
||||
public abstract function diff() : string;
|
||||
|
||||
|
||||
public abstract function status($path) : string;
|
||||
|
|
|
@ -34,7 +34,7 @@ use pocketmine\Player;
|
|||
class Main extends PluginBase implements Listener {
|
||||
protected $git;
|
||||
|
||||
const PREFIX = C::BLACK . "[" . C::LIGHT_GRAY . "Git" . C::BLACK . "] " . C::LIGHT_GRAY;
|
||||
const PREFIX = C::BLACK .C::BOLD . C::ITALIC . "[" . C::RESET . C::BOLD .C::GRAY . "Git" . C::BLACK . C::ITALIC . "] " . C::RESET . C::GRAY;
|
||||
|
||||
|
||||
public function onEnable() {
|
||||
|
@ -69,7 +69,25 @@ class Main extends PluginBase implements Listener {
|
|||
|
||||
case "cd":
|
||||
$this->git->cd($args[1]);
|
||||
$sender->sendMessage("New path: " . $this->git->getDir());
|
||||
$sender->sendMessage(self::PREFIX . "New path: " . $this->git->getDir());
|
||||
break;
|
||||
|
||||
case "commit":
|
||||
unset($args[0]);
|
||||
$sender->sendMessage(self::PREFIX . $this->git->commit(implode(" ", $args)));
|
||||
$sender->sendMessage(self::PREFIX . "Commited !");
|
||||
break;
|
||||
|
||||
case "checkout":
|
||||
$sender->sendMessage(self::PREFIX . $this->git->checkout($args[1]));
|
||||
break;
|
||||
|
||||
case "dir":
|
||||
$sender->sendMessage(self::PREFIX . $this->git->getDir());
|
||||
break;
|
||||
|
||||
case "clone":
|
||||
$sender->sendMessage(self::PREFIX . $this->git->clone($args[1]));
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -27,17 +27,20 @@ class Windows extends GitClient {
|
|||
|
||||
|
||||
public function commit(string $message) : string {
|
||||
return shell_exec("git commit -m \"$message\"");
|
||||
$handle = popen("git commit -m \"$message\"", 'r');
|
||||
return fread($handle, 2096);
|
||||
}
|
||||
|
||||
|
||||
public function push(string $to = "github", string $from = "master") : string {
|
||||
return shell_exec("git push $to $from");
|
||||
$handle = popen("git push $to $from", 'r');
|
||||
return fread($handle, 2096);
|
||||
}
|
||||
|
||||
|
||||
public function checkout($branch = null) : string {
|
||||
return shell_exec("git checkout " . (!is_null($branch) ? $this->getBranch() : $branch));
|
||||
$handle = popen("git checkout " . (!is_null($branch) ? $this->getBranch() : $branch), 'r');
|
||||
return fread($handle, 2096);
|
||||
}
|
||||
|
||||
|
||||
|
@ -49,17 +52,20 @@ class Windows extends GitClient {
|
|||
|
||||
|
||||
public function branch($branch = '') : string {
|
||||
return shell_exec("git branch " . $branch);
|
||||
$handle = popen("git branch " . $branch, 'r');
|
||||
return fread($handle, 2096);
|
||||
}
|
||||
|
||||
|
||||
public function start() : string {
|
||||
return shell_exec("git init");
|
||||
$handle = popen("git init", 'r');
|
||||
return fread($handle, 2096);
|
||||
}
|
||||
|
||||
|
||||
public function init() : string {
|
||||
return shell_exec("git init");
|
||||
$handle = popen("git init", 'r');
|
||||
return fread($handle, 2096);
|
||||
}
|
||||
|
||||
public function getDir() {
|
||||
|
@ -79,38 +85,56 @@ class Windows extends GitClient {
|
|||
|
||||
|
||||
public function clone($from) : string {
|
||||
$handle = popen("git clone $from", 'r');
|
||||
return fread($handle, 2096);
|
||||
}
|
||||
|
||||
|
||||
public function log() : string {
|
||||
$handle = popen("git log", 'r');
|
||||
return fread($handle, 2096);
|
||||
}
|
||||
|
||||
|
||||
public function remove($path) : string {
|
||||
$handle = popen("git rm $path", 'r');
|
||||
return fread($handle, 2096);
|
||||
}
|
||||
|
||||
|
||||
public function move($path, $newpath) : string {
|
||||
$handle = popen("git mv $path $newpath", 'r');
|
||||
return fread($handle, 2096);
|
||||
}
|
||||
|
||||
|
||||
public function add($path) : string {
|
||||
$handle = popen("git add $path", 'r');
|
||||
return fread($handle, 2096);
|
||||
}
|
||||
|
||||
|
||||
public function diff($path) : string {
|
||||
public function diff() : string {
|
||||
$handle = popen("git diff $path", 'r');
|
||||
return fread($handle, 2096);
|
||||
}
|
||||
|
||||
|
||||
public function status($path) : string {
|
||||
public function status() : string {
|
||||
$handle = popen("git status -s", 'r');
|
||||
return fread($handle, 2096);
|
||||
}
|
||||
|
||||
|
||||
public function remote($name, $url) : string {
|
||||
$handle = popen("git remote $name $url", 'r');
|
||||
return fread($handle, 2096);
|
||||
}
|
||||
|
||||
|
||||
public function pull($to = "github", $from = "master") : string {
|
||||
$handle = popen("git pull $to $from", 'r');
|
||||
return fread($handle, 2096);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue