timoschinkel/codeowners-cli

A cli interface for the codeowners library

1.4.0 2022-12-09 11:01 UTC

This package is auto-updated.

Last update: 2024-04-09 14:17:19 UTC


README

Code owners CLI is a CLI interface to simplify common operations on Code owners files using timoschinkel/codeowners.

Installation

Use Composer for installation:

composer require timoschinkel/codeowners-cli

If 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-cli

Usage

When 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:$PATH

All 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.

Available commands

owner

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

For example:

codeowners owner ./src

list-files

Shows 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>/CODEOWNERS

For example:

codeowners list-files @team ./src

The output of this command can be used to feed into other tools using xargs:

codeowners list-files @team ./src | xargs <command>

list-unowned-files

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

For example:

codeowners list-unowned-files ./src

list-owners

Shows 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>/CODEOWNERS

For example:

codeowners list-owners