Code owners CLI is a CLI interface to simplify common operations on Code owners files using timoschinkel/codeowners.
Use Composer for installation:
composer require timoschinkel/codeowners-cliIf you don't want Code owners CLI to be part of your project to can opt to install it globally:
composer global require timoschinkel/codeowners-cliWhen installed as dependency of your project:
./vendor/bin/codeowners [options] <command>When installed globally:
codeowners [options] <command>NB When installed globally you will need to install Composer itself globally add the global Composer binary folder to your PATH variable, eg by adding the following line to ~/.bash_profile or ~/.bashrc:
export PATH=~/.composer/vendor/bin:$PATHAll commands have the options supplied by Symfony Console:
-q,--quiet; Do no output any message-v|vv|vvv,--verbose; Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
When no CODEOWNERS file is specified - using -c or --codeowners - the application will search the CODEOWNERS file in the following locations based on the working directory:
<working_dir>/.github/CODEOWNERS<working_dir>/.bitbucket/CODEOWNERS<working_dir>/.gitlab/CODEOWNERS<working_dir>/CODEOWNERS<working_dir>/docs/CODEOWNERS
Calling the command with the verbose option will print what file is used when applicable.
Shows the owner of the path(s) passed as parameter.
Usage:
owner [options] [--] <paths>...
Arguments:
paths Paths to files or directories to show code owner, separate with spaces
Options:
-c, --codeowners=CODEOWNERS Location of code owners file, defaults to <working_dir>/CODEOWNERS
-o, --owner-only Suppress normal output, only output the owner when applicableFor example:
codeowners owner ./srcShows all files for an owner:
Usage:
list-files [options] [--] <owner> <paths>...
Arguments:
owner Codeowner for which the files should be listed
paths Paths to files or directories to show code owner, separate with spaces
Options:
-c, --codeowners=CODEOWNERS Location of code owners file, defaults to <working_dir>/CODEOWNERSFor example:
codeowners list-files @team ./srcThe output of this command can be used to feed into other tools using xargs:
codeowners list-files @team ./src | xargs <command>Shows all files that don't have an owner specified:
Usage:
list-unowned-files [options] [--] <paths>...
Arguments:
paths Paths to files or directories to show code owner, separate with spaces
Options:
-c, --codeowners=CODEOWNERS Location of code owners file, defaults to <working_dir>/CODEOWNERS
--strict Return a non-zero exit code when there are unowned filesFor example:
codeowners list-unowned-files ./srcShows all available owners inside the found CODEOWNERS file.
Usage:
list-owners [options]
Options:
-c, --codeowners=CODEOWNERS Location of code owners file, defaults to <working_dir>/CODEOWNERSFor example:
codeowners list-owners