Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: php-toolkit/cli-utils
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.2.7
Choose a base ref
...
head repository: php-toolkit/cli-utils
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Loading
Showing with 3,663 additions and 1,794 deletions.
  1. +37 −0 .github/changelog.yml
  2. +13 −0 .github/dependabot.yml
  3. +10 −10 .github/workflows/php.yml
  4. +14 −35 .github/workflows/release.yml
  5. +1 −0 .gitignore
  6. +8 −3 .php_cs → .php-cs-fixer.php
  7. +75 −89 README.md
  8. +6 −3 composer.json
  9. BIN example/cli-app.png
  10. +3 −8 example/down.php
  11. BIN example/images/cli-app.png
  12. BIN example/images/clog-example.png
  13. BIN example/images/color-styles.png
  14. BIN example/images/down-file-bar.jpg
  15. +26 −0 example/keyboard.php
  16. +0 −68 example/liteApp
  17. +17 −0 example/log.php
  18. +23 −0 example/mycmd
  19. +55 −0 example/readline/cb_handler.php
  20. +91 −0 example/readline/cb_handler2.php
  21. +71 −0 example/readline/complete.php
  22. +52 −0 example/readline/readline.php
  23. +77 −0 example/term_move.php
  24. +13 −0 phpunit.xml
  25. +0 −23 phpunit.xml.dist
  26. +0 −657 src/App.php
  27. +135 −31 src/Cli.php
  28. +606 −0 src/CliApp.php
  29. +109 −179 src/Color.php
  30. +116 −0 src/Color/ANSICode.php
  31. +146 −0 src/Color/Alert.php
  32. +11 −13 src/{ → Color}/ColorCode.php
  33. +55 −34 src/{ → Color}/ColorTag.php
  34. +138 −0 src/Color/Prompt.php
  35. +0 −359 src/Flags.php
  36. +107 −0 src/Helper/CliHelper.php
  37. +283 −0 src/Helper/FlagHelper.php
  38. +28 −20 src/Style.php
  39. +65 −14 src/Traits/ReadMessageTrait.php
  40. +80 −45 src/Traits/WriteMessageTrait.php
  41. +254 −0 src/Util/CliLogger.php
  42. +107 −0 src/Util/Clog.php
  43. +14 −15 src/Util/Download.php
  44. +13 −13 src/Util/Highlighter.php
  45. +43 −0 src/Util/Keyboard.php
  46. +3 −3 src/Util/LineParser.php
  47. +256 −0 src/Util/Readline.php
  48. +231 −83 src/Util/Terminal.php
  49. +4 −8 src/Highlighter.php → test/BaseCliTestCase.php
  50. +41 −0 test/CliTest.php
  51. +2 −2 test/{ → Color}/ColorCodeTest.php
  52. +27 −1 test/ColorTagTest.php
  53. +2 −1 test/ColorTest.php
  54. +0 −73 test/FlagsTest.php
  55. +126 −0 test/Helper/FlagHelperTest.php
  56. +27 −0 test/StyleTest.php
  57. +32 −0 test/Util/ClogTest.php
  58. +10 −4 test/bootstrap.php
37 changes: 37 additions & 0 deletions .github/changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
title: '## Change Log'
# style allow: simple, markdown(mkdown), ghr(gh-release)
style: gh-release
# group names
names: [Refactor, Fixed, Feature, Update, Other]
# if empty will auto fetch by git remote
#repo_url: https://github.com/gookit/gitw

filters:
# message length should >= 12
- name: msg_len
min_len: 12
# message words should >= 3
- name: words_len
min_len: 3
- name: keyword
keyword: format code
exclude: true
- name: keywords
keywords: format code, action test
exclude: true

# group match rules
# not matched will use 'Other' group.
rules:
- name: Refactor
start_withs: [refactor, break]
contains: ['refactor:']
- name: Fixed
start_withs: [fix]
contains: ['fix:']
- name: Feature
start_withs: [feat, new]
contains: ['feat:']
- name: Update
start_withs: [update]
contains: ['update:', 'up:']
13 changes: 13 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: 2
updates:
- package-ecosystem: composer
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10

- package-ecosystem: "github-actions"
directory: "/"
schedule:
# Check for updates to GitHub Actions every weekday
interval: "daily"
20 changes: 10 additions & 10 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -15,19 +15,19 @@ jobs:
strategy:
fail-fast: true
matrix:
php: [7.3, 7.4, 8.0]
php: [8.1, 8.2, 8.3, 8.4]
os: [ubuntu-latest, macOS-latest] # windows-latest,
include:
- os: 'ubuntu-latest'
php: '7.2'
phpunit: '8.5.13'
- os: 'ubuntu-latest'
php: '7.1'
phpunit: '7.5.20'
# include:
# - os: 'ubuntu-latest'
# php: '7.2'
# phpunit: '8.5.13'
# - os: 'ubuntu-latest'
# php: '7.1'
# phpunit: '7.5.20'

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

# usage refer https://github.com/shivammathur/setup-php
- name: Setup PHP
@@ -51,4 +51,4 @@ jobs:

- name: Run unit tests
# run: composer run test
run: phpunit -vv
run: phpunit
49 changes: 14 additions & 35 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -7,56 +7,35 @@ on:

jobs:
release:
name: Test on php ${{ matrix.php}}
name: Release new version
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
fail-fast: true
matrix:
php: [7.3]

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set ENV for github-release
# https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
run: |
echo "RELEASE_TAG=${GITHUB_REF:10}" >> $GITHUB_ENV
echo "RELEASE_NAME=$GITHUB_WORKFLOW" >> $GITHUB_ENV
# usage refer https://github.com/shivammathur/setup-php
- name: Setup PHP
timeout-minutes: 5
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php}}
tools: pecl, php-cs-fixer
extensions: mbstring, dom, fileinfo, mysql, openssl # , swoole-4.4.19 #optional, setup extensions
ini-values: post_max_size=56M, short_open_tag=On #optional, setup php.ini configuration
coverage: none #optional, setup coverage driver: xdebug, none

- name: Install dependencies # eg: v1.0.3
- name: Generate changelog
run: |
tag1=${GITHUB_REF#refs/*/}
echo "release tag: ${tag1}"
composer install --no-progress
# Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit"
# Docs: https://getcomposer.org/doc/articles/scripts.md

# - name: Build phar and send to github assets
# run: |
# echo $RELEASE_TAG
# echo $RELEASE_NAME
# php -d phar.readonly=0 bin/kite phar:pack -o kite-${RELEASE_TAG}.phar --no-progress
# php kite-${RELEASE_TAG}.phar -V
curl https://github.com/gookit/gitw/releases/latest/download/chlog-linux-amd64 -L -o /usr/local/bin/chlog
chmod a+x /usr/local/bin/chlog
chlog -c .github/changelog.yml -o changelog.md prev last
# https://github.com/actions/create-release
- uses: meeDamian/github-release@2.0
# https://github.com/softprops/action-gh-release
- name: Create release and upload assets
uses: softprops/action-gh-release@v2
with:
gzip: false
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ env.RELEASE_TAG }}
name: ${{ env.RELEASE_TAG }}
# files: kite-${{ env.RELEASE_TAG }}.phar
tag_name: ${{ env.RELEASE_TAG }}
body_path: changelog.md
# files: kite-${{ env.RELEASE_TAG }}.phar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
!README.md
!.gitkeep
composer.lock
*.txt
*.swp
*.log
*.pid
11 changes: 8 additions & 3 deletions .php_cs → .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -3,18 +3,21 @@
$header = <<<'EOF'
This file is part of toolkit/cli-utils.
@homepage https://github.com/php-toolkit/cli-utils
@link https://github.com/php-toolkit/cli-utils
@author https://github.com/inhere
@license MIT
EOF;

return (new PhpCsFixer\Config)
return (new PhpCsFixer\Config())
->setRiskyAllowed(true)
->setRules([
'@PSR2' => true,
'array_syntax' => [
'syntax' => 'short'
],
'list_syntax' => [
'syntax' => 'short'
],
'class_attributes_separation' => true,
'declare_strict_types' => true,
'global_namespace_import' => [
@@ -29,11 +32,13 @@
'no_unused_imports' => true,
'single_quote' => true,
'standardize_not_equals' => true,
'void_return' => true, // add :void for method
])
->setFinder(
PhpCsFixer\Finder::create()
// ->exclude('test')
->exclude('test')
->exclude('runtime')
->exclude('.github')
->exclude('vendor')
->in(__DIR__)
)
Loading