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
api: [2.0.0]
main: Ad5001\Gitable\Main
commands: []
permissions: []
commands:
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\utils\TextFormat as C;
use pocketmine\Server;
@ -31,6 +34,8 @@ use pocketmine\Player;
class Main extends PluginBase implements Listener {
protected $git;
const PREFIX = C::BLACK . "[" . C::LIGHT_GRAY . "Git" . C::BLACK . "] " . C::LIGHT_GRAY;
public function onEnable() {
@ -58,17 +63,16 @@ class Main extends PluginBase implements Listener {
case 'git':
if(count($args) >= 1) {
if(count($args) >= 2) {
if(isset(self::COMMANDS[$args[0]])) {
$cmd = $args[0];
unset($args[0]);
$sender->sendMessage($this->git->{self::COMMANDS[$cmd][0]}(implode(" ", $args)));
switch($args[0]) {
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 {
public function commit(string $message) : string {
return shell_exec("git commit -m \"$message\"");
}
public function push(string $to = "github", string $from = "master") : string {
return shell_exec("git push $to $from");
}
public function checkout($branch = null) : string {
return shell_exec("git checkout " . (!is_null($branch) ? $this->getBranch() : $branch));
}
public function getBranch() : string {
$handle = popen('git branch', 'r');
$read = fread($handle, 2096);
return explode(" ", $read)[1];
}
public function branch($branch = '') : string {
return shell_exec("git branch " . $branch);
}
public function start() : string {
return shell_exec("git init");
}
public function init() : string {
return shell_exec("git init");
}
public function getDir() {
return $this->dir;
}
public function cd($path) : string {
return shell_exec("cd " . $path);
}
public function clone($from) : string {}
public function log() : string {}
public function remove($path) : string {}
public function move($path, $newpath) : string {}
public function add($path) : 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 {}
}
public function commit(string $message) : string {
return shell_exec("git commit -m \"$message\"");
}
public function push(string $to = "github", string $from = "master") : string {
return shell_exec("git push $to $from");
}
public function checkout($branch = null) : string {
return shell_exec("git checkout " . (!is_null($branch) ? $this->getBranch() : $branch));
}
public function getBranch() : string {
$handle = popen('git branch', 'r');
$read = fread($handle, 2096);
return explode(" ", $read)[1];
}
public function branch($branch = '') : string {
return shell_exec("git branch " . $branch);
}
public function start() : string {
return shell_exec("git init");
}
public function init() : string {
return shell_exec("git init");
}
public function getDir() {
return $this->dir;
}
public function cd($path) : string {
if(is_dir($path)) {
$dir = chdir($path);
$this->dir = getcwd();
return (string) $dir;
} else {
return "Directory $path not found !";
}
}
public function clone($from) : string {
}
public function log() : string {
}
public function remove($path) : string {
}
public function move($path, $newpath) : string {
}
public function add($path) : 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 {
}
}