Browse Source

Still working on it...

tags/v1.0
Ad5001 3 years ago
parent
commit
d54dc7c799
3 changed files with 116 additions and 91 deletions
  1. 8
    2
      plugin.yml
  2. 12
    8
      src/Ad5001/Gitable/Main.php
  3. 96
    81
      src/Ad5001/Gitable/Windows.php

+ 8
- 2
plugin.yml 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
...

+ 12
- 8
src/Ad5001/Gitable/Main.php 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(isset(self::COMMANDS[$args[0]])) {

$cmd = $args[0];

unset($args[0]);
if(count($args) >= 2) {

$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;
}



+ 96
- 81
src/Ad5001/Gitable/Windows.php 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 {
}
}

Loading…
Cancel
Save