Skip to content

Commit

Permalink
upsome
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Jun 16, 2020
1 parent 7ce42d7 commit cab39b1
Show file tree
Hide file tree
Showing 5 changed files with 148 additions and 8 deletions.
46 changes: 45 additions & 1 deletion app/Common/GitLocal/GitHub.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,40 @@
*/
class GitHub extends AbstractGitLocal
{
/**
* @var array
*/
private $projects;

/**
* current project owner/group name
*
* @var string
*/
private $curOwner = '';

/**
* current project name
*
* @var string
*/
private $curPName = '';

/**
* @var string
*/
private $curBranch = '';

/**
* @var string
*/
private $srcBranch = '';

/**
* @var string
*/
private $dstBranch = '';

/**
* Class constructor.
*
Expand All @@ -24,11 +58,21 @@ public function __construct(array $config = [])
$this->host = self::GITHUB_HOST;
}

/**
* @param string $owner
* @param string $pName
*/
public function setCurrent(string $owner, string $pName): void
{
$this->curOwner = $owner;
$this->curPName = $pName;
}

/**
* @param string $host
*/
public function setHost(string $host): void
{
throw new RuntimeException('The host is fixed for github, cannot change it.');
throw new RuntimeException('The github host is fixed, cannot change it.');
}
}
39 changes: 37 additions & 2 deletions app/Common/GitLocal/GitLab.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,26 @@ class GitLab extends AbstractGitLocal
*/
private $projects;

/**
* @var string
*/
private $curPjName = '';

/**
* @var string
*/
private $curBranch = '';

/**
* @var string
*/
private $srcBranch = '';

/**
* @var string
*/
private $dstBranch = '';

/**
* Class constructor.
*
Expand All @@ -28,9 +48,9 @@ public function __construct(array $config = [])
$this->config = $config;
}

public function createPRLink(string $pjName): string
public function createPRLink(string $srcBranch, string $dstBranch, bool $direct = false): string
{

return '';
}

/**
Expand All @@ -49,4 +69,19 @@ public function setProjects(array $projects): void
$this->projects = $projects;
}

/**
* @return string
*/
public function getCurPjName(): string
{
return $this->curPjName;
}

/**
* @param string $curPjName
*/
public function setCurPjName(string $curPjName): void
{
$this->curPjName = $curPjName;
}
}
40 changes: 35 additions & 5 deletions app/Console/Command/DocCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@
use Inhere\Console\Command;
use Inhere\Console\IO\Input;
use Inhere\Console\IO\Output;
use Inhere\Console\Util\Helper;
use Inhere\Kite\Common\CliMarkdown;
use Inhere\Kite\Helper\AppHelper;
use Inhere\Kite\ManDoc\DocTopic;
use Inhere\Kite\ManDoc\Document;
use Toolkit\Cli\Color;
use Toolkit\Sys\Proc\ProcWrapper;
use function array_pop;
use function dirname;
use function implode;
use function rtrim;
use function str_replace;

Expand Down Expand Up @@ -131,7 +135,7 @@ protected function execute($input, $output)
$topic = $man->findTopic($this->topName, $this->subNames);
if (!$topic) {
if ($input->getBoolOpt('create')) {
$this->createTopic($output);
$this->createTopic($man, $output, $nameString);
return;
}

Expand Down Expand Up @@ -163,11 +167,32 @@ protected function execute($input, $output)
}

/**
* @param Output $output
* @param Document $doc
* @param Output $output
*/
private function createTopic(Output $output): void
private function createTopic(Document $doc, Output $output, string $nameString): void
{
$output->notice('TODO');
$path = $this->topName;
if ($this->subNames) {
$path .= '/' . implode('/', $this->subNames);
}

$realPaths = $doc->getRealPaths();
$lastPath = array_pop($realPaths);
$filepath = $lastPath . '/' . $path . Document::EXT;

$output->info('will create document #' . $nameString);
$output->aList([
'topic' => $nameString,
'file' => $filepath,
], 'document info', ['ucFirst' => false]);

Helper::mkdir(dirname($filepath), 0755);

$editor = $this->input->getStringOpt('editor', 'vim');
ProcWrapper::runEditor($editor, $filepath);

$output->success('new document is created');
}

/**
Expand All @@ -181,6 +206,8 @@ private function editTopic(DocTopic $topic): void
$this->output->title("will use '{$editor}' for edit the document");

ProcWrapper::runEditor($editor, $filepath);

$this->output->success('the document is changed');
}

/**
Expand Down Expand Up @@ -215,12 +242,15 @@ private function listTopicInfo(Document $man, string $nameString): void
return;
}

// is topic dir.
$topics = $topic->getChildsInfo();
$default = $topic->getDefault();

$info = [
'metadata' => [
'name' => $topic->getName(),
'node' => '#' . $nameString,
'file' => $topic->getPath(),
'file' => $default ? $default->getPath() : 'No default file',
],
'topics' => $topics,
];
Expand Down
1 change: 1 addition & 0 deletions app/ManDoc/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Document
{
public const EXT = '.md';

public const DEF_EDITOR = 'vim';
public const DEF_TOPIC = 'common';
public const DEF_LANG = 'en';

Expand Down
30 changes: 30 additions & 0 deletions resource/mandocs/en/mysql/alter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# alter

examples for use `alter` on mysql

## add column

add new column example:

```sql
alter table my_table
ADD COLUMN new_field int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'my new field';
```

## change column

change column example:

```sql
alter table my_table
CHANGE COLUMN old_field old_field int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'my new field';
```

## drop column

drop column example:

```sql
alter table my_table DROP old_field;
```

0 comments on commit cab39b1

Please sign in to comment.