mirror of
https://github.com/n3w/helpers-functions-cli.git
synced 2025-12-19 12:43:22 +00:00
chore: Update README, LICENCE, and add code linting
This commit is contained in:
parent
33090aee1f
commit
b9a3034788
8 changed files with 145 additions and 7 deletions
2
.gitattributes
vendored
Normal file
2
.gitattributes
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
# Force LF
|
||||||
|
* text eol=lf
|
||||||
41
.php-commitizen.php
Normal file
41
.php-commitizen.php
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
return [
|
||||||
|
'type' => [
|
||||||
|
'lengthMin' => 3,
|
||||||
|
'lengthMax' => 8,
|
||||||
|
'acceptExtra' => false,
|
||||||
|
'values' => [
|
||||||
|
'feat',
|
||||||
|
'fix',
|
||||||
|
'docs',
|
||||||
|
'chore',
|
||||||
|
'test',
|
||||||
|
'refactor',
|
||||||
|
'revert',
|
||||||
|
'ci',
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'scope' => [
|
||||||
|
'lengthMin' => 0,
|
||||||
|
'lengthMax' => 10,
|
||||||
|
'acceptExtra' => true,
|
||||||
|
'values' => [],
|
||||||
|
],
|
||||||
|
'description' => [
|
||||||
|
'lengthMin' => 1,
|
||||||
|
'lengthMax' => 47,
|
||||||
|
],
|
||||||
|
'subject' => [
|
||||||
|
'lengthMin' => 1,
|
||||||
|
'lengthMax' => 69,
|
||||||
|
],
|
||||||
|
'body' => [
|
||||||
|
'wrap' => 72,
|
||||||
|
],
|
||||||
|
'footer' => [
|
||||||
|
'wrap' => 72,
|
||||||
|
],
|
||||||
|
];
|
||||||
59
.php-cs-fixer.dist.php
Normal file
59
.php-cs-fixer.dist.php
Normal file
|
|
@ -0,0 +1,59 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
$header = <<<EOF
|
||||||
|
This file is part of the "PHP Helpers: Command-line Functions" repository.
|
||||||
|
|
||||||
|
Copyright 2019-2021 Alannah Kearney <hi@alannahkearney.com>
|
||||||
|
|
||||||
|
For the full copyright and license information, please view the LICENCE
|
||||||
|
file that was distributed with this source code.
|
||||||
|
EOF;
|
||||||
|
|
||||||
|
return (new PhpCsFixer\Config())
|
||||||
|
->setUsingCache(true)
|
||||||
|
->setRiskyAllowed(true)
|
||||||
|
->setFinder(
|
||||||
|
(new PhpCsFixer\Finder())
|
||||||
|
->files()
|
||||||
|
->name('*.php')
|
||||||
|
->in(__DIR__)
|
||||||
|
->exclude(__DIR__.'/vendor')
|
||||||
|
)
|
||||||
|
->setRules([
|
||||||
|
'@PSR2' => true,
|
||||||
|
'@Symfony' => true,
|
||||||
|
'is_null' => true,
|
||||||
|
'blank_line_before_statement' => ['statements' => ['continue', 'declare', 'return', 'throw', 'try']],
|
||||||
|
'cast_spaces' => ['space' => 'single'],
|
||||||
|
'header_comment' => ['header' => $header],
|
||||||
|
'include' => true,
|
||||||
|
'class_attributes_separation' => ['elements' => ['const' => 'one', 'method' => 'one', 'property' => 'one']],
|
||||||
|
'no_blank_lines_after_class_opening' => true,
|
||||||
|
'no_blank_lines_after_phpdoc' => true,
|
||||||
|
'no_empty_statement' => true,
|
||||||
|
'no_extra_blank_lines' => true,
|
||||||
|
'no_leading_import_slash' => true,
|
||||||
|
'no_leading_namespace_whitespace' => true,
|
||||||
|
'no_trailing_comma_in_singleline_array' => true,
|
||||||
|
'no_unused_imports' => true,
|
||||||
|
'no_whitespace_in_blank_line' => true,
|
||||||
|
'object_operator_without_whitespace' => true,
|
||||||
|
'phpdoc_align' => true,
|
||||||
|
'phpdoc_indent' => true,
|
||||||
|
'phpdoc_no_access' => true,
|
||||||
|
'phpdoc_no_package' => true,
|
||||||
|
'phpdoc_order' => true,
|
||||||
|
'phpdoc_scalar' => true,
|
||||||
|
'phpdoc_trim' => true,
|
||||||
|
'phpdoc_types' => true,
|
||||||
|
'psr_autoloading' => true,
|
||||||
|
'array_syntax' => ['syntax' => 'short'],
|
||||||
|
'declare_strict_types' => true,
|
||||||
|
'single_blank_line_before_namespace' => true,
|
||||||
|
'standardize_not_equals' => true,
|
||||||
|
'ternary_operator_spaces' => true,
|
||||||
|
'trailing_comma_in_multiline' => true,
|
||||||
|
])
|
||||||
|
;
|
||||||
|
|
@ -3,6 +3,13 @@
|
||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
This project adheres to [Semantic Versioning](http://semver.org/).
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
||||||
|
|
||||||
|
## [1.1.10][]
|
||||||
|
#### Added
|
||||||
|
- Added `which()` function
|
||||||
|
|
||||||
|
#### Changed
|
||||||
|
- Refactor of `run_command()` function to return an exit code
|
||||||
|
|
||||||
## [1.1.9][]
|
## [1.1.9][]
|
||||||
#### Added
|
#### Added
|
||||||
- Added `run_command()` function
|
- Added `run_command()` function
|
||||||
|
|
|
||||||
2
LICENCE
2
LICENCE
|
|
@ -3,7 +3,7 @@ unless otherwise specified, released under the MIT licence as follows:
|
||||||
|
|
||||||
----- begin license block -----
|
----- begin license block -----
|
||||||
|
|
||||||
Copyright 2019-2020 Alannah Kearney
|
Copyright 2019-2021 Alannah Kearney
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
# PHP Helpers: Command-line Functions
|
# PHP Helpers: Command-line Functions
|
||||||
|
|
||||||
- Version: v1.1.9
|
- Version: v1.1.10
|
||||||
- Date: April 06 2020
|
- Date: July 29 2021
|
||||||
- [Release notes](https://github.com/pointybeard/helpers-functions-cli/blob/master/CHANGELOG.md)
|
- [Release notes](https://github.com/pointybeard/helpers-functions-cli/blob/master/CHANGELOG.md)
|
||||||
- [GitHub repository](https://github.com/pointybeard/helpers-functions-cli)
|
- [GitHub repository](https://github.com/pointybeard/helpers-functions-cli)
|
||||||
|
|
||||||
|
|
@ -28,6 +28,8 @@ This library is a collection convenience function for command-line tasks. They a
|
||||||
|
|
||||||
The following functions are provided:
|
The following functions are provided:
|
||||||
|
|
||||||
|
- `run_command()`
|
||||||
|
- `which()`
|
||||||
- `can_invoke_bash()`
|
- `can_invoke_bash()`
|
||||||
- `is_su()`
|
- `is_su()`
|
||||||
- `run_command()`
|
- `run_command()`
|
||||||
|
|
@ -48,6 +50,9 @@ use pointybeard\Helpers\Cli\Input;
|
||||||
use pointybeard\Helpers\Cli\Colour\Colour;
|
use pointybeard\Helpers\Cli\Colour\Colour;
|
||||||
use pointybeard\Helpers\Functions\Cli;
|
use pointybeard\Helpers\Functions\Cli;
|
||||||
|
|
||||||
|
var_dump(Cli\which("ls"));
|
||||||
|
// string(11) "/usr/bin/ls"
|
||||||
|
|
||||||
var_dump(Cli\can_invoke_bash());
|
var_dump(Cli\can_invoke_bash());
|
||||||
// bool(true)
|
// bool(true)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,11 @@
|
||||||
"description": "A collection of functions relating to the command-line",
|
"description": "A collection of functions relating to the command-line",
|
||||||
"homepage": "https://github.com/pointybeard/helpers-functions-cli",
|
"homepage": "https://github.com/pointybeard/helpers-functions-cli",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"minimum-stability": "stable",
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/pointybeard/helpers-functions-cli/issues",
|
||||||
|
"wiki": "https://github.com/pointybeard/helpers-functions-cli/wiki"
|
||||||
|
},
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
"name": "Alannah Kearney",
|
"name": "Alannah Kearney",
|
||||||
|
|
@ -21,11 +26,13 @@
|
||||||
"pointybeard/helpers-functions-debug": "~1.0",
|
"pointybeard/helpers-functions-debug": "~1.0",
|
||||||
"pointybeard/helpers-exceptions-readabletrace": "~1.0.0"
|
"pointybeard/helpers-exceptions-readabletrace": "~1.0.0"
|
||||||
},
|
},
|
||||||
"support": {
|
"require-dev": {
|
||||||
"issues": "https://github.com/pointybeard/helpers-functions-cli/issues",
|
"friendsofphp/php-cs-fixer": "^3.0",
|
||||||
"wiki": "https://github.com/pointybeard/helpers-functions-cli/wiki"
|
"squizlabs/php_codesniffer": "^3.0",
|
||||||
|
"damianopetrungaro/php-commitizen": "^0.1.0",
|
||||||
|
"php-parallel-lint/php-parallel-lint": "^1.0",
|
||||||
|
"php-parallel-lint/php-console-highlighter": "^0.5.0"
|
||||||
},
|
},
|
||||||
"minimum-stability": "stable",
|
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"pointybeard\\Helpers\\Functions\\": "src/"
|
"pointybeard\\Helpers\\Functions\\": "src/"
|
||||||
|
|
@ -33,5 +40,12 @@
|
||||||
"files": [
|
"files": [
|
||||||
"src/Cli/Cli.php"
|
"src/Cli/Cli.php"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"tidy": "php-cs-fixer fix -v --using-cache=no",
|
||||||
|
"tidyDry": "@tidy --dry-run",
|
||||||
|
"test": [
|
||||||
|
"parallel-lint . --exclude vendor"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,15 @@
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the "PHP Helpers: Command-line Functions" repository.
|
||||||
|
*
|
||||||
|
* Copyright 2019-2021 Alannah Kearney <hi@alannahkearney.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENCE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
namespace pointybeard\Helpers\Functions\Cli\Exceptions;
|
namespace pointybeard\Helpers\Functions\Cli\Exceptions;
|
||||||
|
|
||||||
use pointybeard\Helpers\Exceptions\ReadableTrace;
|
use pointybeard\Helpers\Exceptions\ReadableTrace;
|
||||||
|
|
@ -9,6 +18,7 @@ use pointybeard\Helpers\Exceptions\ReadableTrace;
|
||||||
class RunCommandFailedException extends ReadableTrace\ReadableTraceException
|
class RunCommandFailedException extends ReadableTrace\ReadableTraceException
|
||||||
{
|
{
|
||||||
private $command;
|
private $command;
|
||||||
|
|
||||||
private $error;
|
private $error;
|
||||||
|
|
||||||
public function __construct(string $command, string $error, int $code = 0, \Exception $previous = null)
|
public function __construct(string $command, string $error, int $code = 0, \Exception $previous = null)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue