diff --git a/CHANGELOG.md b/CHANGELOG.md index d875479..12fd545 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## [1.1.9][] +#### Added +- Added `run_command()` function +- Added `RunCommandFailedException` exception +- Added `pointybeard/helpers-exceptions-readabletrace` package + ## [1.1.8][] #### Changed - Updated `manpage()` to work with `pointybeard/helpers-cli-input` 1.2 @@ -53,6 +59,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). #### Added - Initial release +[1.1.9]: https://github.com/pointybeard/helpers-functions-cli/compare/1.1.8...1.1.9 [1.1.8]: https://github.com/pointybeard/helpers-functions-cli/compare/1.1.7...1.1.8 [1.1.7]: https://github.com/pointybeard/helpers-functions-cli/compare/1.1.6...1.1.7 [1.1.6]: https://github.com/pointybeard/helpers-functions-cli/compare/1.1.5...1.1.6 diff --git a/LICENCE b/LICENCE index 7d77cd1..cb582d5 100644 --- a/LICENCE +++ b/LICENCE @@ -3,7 +3,7 @@ unless otherwise specified, released under the MIT licence as follows: ----- begin license block ----- -Copyright 2019 Alannah Kearney +Copyright 2019-2020 Alannah Kearney Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 3b79609..bf596c6 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # PHP Helpers: Command-line Functions -- Version: v1.1.8 -- Date: June 01 2019 +- Version: v1.1.9 +- Date: April 06 2020 - [Release notes](https://github.com/pointybeard/helpers-functions-cli/blob/master/CHANGELOG.md) - [GitHub repository](https://github.com/pointybeard/helpers-functions-cli) @@ -30,6 +30,7 @@ The following functions are provided: - `can_invoke_bash()` - `is_su()` +- `run_command()` - `usage()` - `manpage()` - `get_window_size()` @@ -59,6 +60,19 @@ var_dump(Cli\get_window_size()); // 'lines' => string(2) "68" // } +Cli\run_command("date", $out); +var_dump($out); +// string(29) "Mon 6 Apr 17:20:29 AEST 2020" + +try{ + Cli\run_command("not -a --command", $out, $err); +} catch(Cli\Exceptions\RunCommandFailedException $ex) { + var_dump($ex->getMessage(), $ex->getCommand(), $ex->getError()); +} +// string(54) "Failed to run command. Returned: sh: 1: not: not found" +// string(16) "not -a --command" +// string(21) "sh: 1: not: not found" + echo Cli\manpage( 'test', '1.0.2', @@ -128,8 +142,7 @@ Cli\display_error_and_exit('Looks like something went wrong!', 'Fatal Error'); ## Support -If you believe you have found a bug, please report it using the [GitHub issue tracker](https://github.com/pointybeard/helpers-functions-cli/issues), -or better yet, fork the library and submit a pull request. +If you believe you have found a bug, please report it using the [GitHub issue tracker](https://github.com/pointybeard/helpers-functions-cli/issues), or better yet, fork the library and submit a pull request. ## Contributing