Still working on it...

This commit is contained in:
Ad5001 2016-09-23 21:52:41 +03:00
parent 76d4e60d53
commit d54dc7c799
3 changed files with 116 additions and 91 deletions

View File

@ -4,6 +4,12 @@ author: Ad5001
version: 1.0 version: 1.0
api: [2.0.0] api: [2.0.0]
main: Ad5001\Gitable\Main main: Ad5001\Gitable\Main
commands: [] commands:
permissions: [] git:
description: "Main Gitable command"
usage: "/git <command> <parameters>"
permission: git.command.git
permissions:
git.command.git:
default: op
... ...

View File

@ -16,6 +16,9 @@ use pocketmine\event\Listener;
use pocketmine\plugin\PluginBase; use pocketmine\plugin\PluginBase;
use pocketmine\utils\TextFormat as C;
use pocketmine\Server; use pocketmine\Server;
@ -31,6 +34,8 @@ use pocketmine\Player;
class Main extends PluginBase implements Listener { class Main extends PluginBase implements Listener {
protected $git; protected $git;
const PREFIX = C::BLACK . "[" . C::LIGHT_GRAY . "Git" . C::BLACK . "] " . C::LIGHT_GRAY;
public function onEnable() { public function onEnable() {
@ -58,17 +63,16 @@ class Main extends PluginBase implements Listener {
case 'git': case 'git':
if(count($args) >= 1) { if(count($args) >= 2) {
if(isset(self::COMMANDS[$args[0]])) { switch($args[0]) {
$cmd = $args[0];
unset($args[0]);
$sender->sendMessage($this->git->{self::COMMANDS[$cmd][0]}(implode(" ", $args)));
case "cd":
$this->git->cd($args[1]);
$sender->sendMessage("New path: " . $this->git->getDir());
break;
} }
return true;
} }

View File

@ -21,84 +21,99 @@ use Ad5001\Gitable\Main;
class Windows extends GitClient { class Windows extends GitClient {
public function commit(string $message) : string { public function commit(string $message) : string {
return shell_exec("git commit -m \"$message\""); return shell_exec("git commit -m \"$message\"");
} }
public function push(string $to = "github", string $from = "master") : string { public function push(string $to = "github", string $from = "master") : string {
return shell_exec("git push $to $from"); return shell_exec("git push $to $from");
} }
public function checkout($branch = null) : string { public function checkout($branch = null) : string {
return shell_exec("git checkout " . (!is_null($branch) ? $this->getBranch() : $branch)); return shell_exec("git checkout " . (!is_null($branch) ? $this->getBranch() : $branch));
} }
public function getBranch() : string { public function getBranch() : string {
$handle = popen('git branch', 'r'); $handle = popen('git branch', 'r');
$read = fread($handle, 2096); $read = fread($handle, 2096);
return explode(" ", $read)[1]; return explode(" ", $read)[1];
} }
public function branch($branch = '') : string { public function branch($branch = '') : string {
return shell_exec("git branch " . $branch); return shell_exec("git branch " . $branch);
} }
public function start() : string { public function start() : string {
return shell_exec("git init"); return shell_exec("git init");
} }
public function init() : string { public function init() : string {
return shell_exec("git init"); return shell_exec("git init");
} }
public function getDir() { public function getDir() {
return $this->dir; return $this->dir;
} }
public function cd($path) : string { public function cd($path) : string {
return shell_exec("cd " . $path); if(is_dir($path)) {
} $dir = chdir($path);
$this->dir = getcwd();
return (string) $dir;
public function clone($from) : string {} } else {
return "Directory $path not found !";
}
public function log() : string {} }
public function remove($path) : string {} public function clone($from) : string {
}
public function move($path, $newpath) : string {}
public function log() : string {
}
public function add($path) : string {}
public function remove($path) : string {
public function diff($path) : string {} }
public function status($path) : string {} public function move($path, $newpath) : string {
}
public function remote($name, $url) : string {}
public function add($path) : string {
}
public function pull($to = "github", $from = "master") : string {}
public function diff($path) : string {
}
}
public function status($path) : string {
}
public function remote($name, $url) : string {
}
public function pull($to = "github", $from = "master") : string {
}
}