Skip to content

Commit 3e36116

Browse files
committed
up: add more help method in Cli and CliHelper
1 parent 4f1825f commit 3e36116

File tree

4 files changed

+55
-21
lines changed

4 files changed

+55
-21
lines changed

.github/changelog.yml

+30-20
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,37 @@
1-
options:
2-
title: '## Chanage Log'
3-
style: gh-release
1+
title: '## Change Log'
2+
# style allow: simple, markdown(mkdown), ghr(gh-release)
3+
style: gh-release
4+
# group names
5+
names: [Refactor, Fixed, Feature, Update, Other]
6+
# if empty will auto fetch by git remote
7+
#repo_url: https://github.com/gookit/gitw
8+
49
filters:
5-
# message length >= 12
6-
- name: msgLen
7-
minLen: 12
8-
# message words >= 3
9-
- name: wordsLen
10-
minLen: 3
10+
# message length should >= 12
11+
- name: msg_len
12+
min_len: 12
13+
# message words should >= 3
14+
- name: words_len
15+
min_len: 3
16+
- name: keyword
17+
keyword: format code
18+
exclude: true
1119
- name: keywords
12-
keywords: ['format code']
20+
keywords: format code, action test
1321
exclude: true
1422

23+
# group match rules
1524
# not matched will use 'Other' group.
16-
groups:
17-
- name: New
18-
contains: [add, new]
25+
rules:
26+
- name: Refactor
27+
start_withs: [refactor, break]
28+
contains: ['refactor:']
1929
- name: Fixed
20-
startWiths: [add, new]
21-
contains: [add, new]
22-
- name: Feat
23-
startWiths: [feat]
24-
contains: [feature]
30+
start_withs: [fix]
31+
contains: ['fix:']
32+
- name: Feature
33+
start_withs: [feat, new]
34+
contains: ['feat:']
2535
- name: Update
26-
startWiths: [update, 'up:']
27-
contains: []
36+
start_withs: [update]
37+
contains: ['update:', 'up:']

.github/workflows/php.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
strategy:
1616
fail-fast: true
1717
matrix:
18-
php: [8.0, 8.1]
18+
php: [8.0, 8.1, 8.2]
1919
os: [ubuntu-latest, macOS-latest] # windows-latest,
2020
# include:
2121
# - os: 'ubuntu-latest'

src/Cli.php

+12
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Toolkit\Cli\Color\Prompt;
1616
use Toolkit\Cli\Traits\ReadMessageTrait;
1717
use Toolkit\Cli\Traits\WriteMessageTrait;
18+
use Toolkit\Stdlib\Str;
1819
use function array_shift;
1920
use function count;
2021
use function date;
@@ -301,4 +302,15 @@ public static function stripAnsiCode(string $string): string
301302
{
302303
return preg_replace('/\033\[[\d;?]*\w/', '', $string);
303304
}
305+
306+
/**
307+
* @param array $args
308+
* @param string $prefix
309+
*
310+
* @return string
311+
*/
312+
public static function toCmdline(array $args, string $prefix = ''): string
313+
{
314+
return Str::shellQuotesToLine($args, $prefix);
315+
}
304316
}

src/Helper/CliHelper.php

+12
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
namespace Toolkit\Cli\Helper;
1111

12+
use Toolkit\Stdlib\Str;
1213
use function escapeshellarg;
1314
use function is_bool;
1415
use function is_numeric;
@@ -92,4 +93,15 @@ public static function escapeToken(string $token): string
9293
{
9394
return preg_match('{^[\w-]+$}', $token) ? $token : escapeshellarg($token);
9495
}
96+
97+
/**
98+
* @param array $args
99+
* @param string $prefix
100+
*
101+
* @return string
102+
*/
103+
public static function toCmdline(array $args, string $prefix = ''): string
104+
{
105+
return Str::shellQuotesToLine($args, $prefix);
106+
}
95107
}

0 commit comments

Comments
 (0)