Repository: duckinator/bork

Issue:
Ability to list all aliases
The command would be something like `bork alias` or `bork aliases`, I guess.

I'm thinking something along the lines of

```
$ cat pyproject.toml
[build-system]
# Specify the required build system.
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"

[tool.bork.zipapp]
# bork can not build a functional zipapp of Emanate yet.
enabled = false
main = "emanate.cli:main"

[tool.bork.aliases]
# Runs *only* pylint and flake8. (Not the actual tests.)
lint = "pytest -k 'flake8 or pylint' --pylint --flake8 --verbose"
# Runs tests, pylint, and flake8.
test = "pytest --pylint --flake8 --verbose"
docs = "env PYTHONPATH=./ pdoc3 --html --output-dir ./html --force emanate"
$ bork aliases
lint
test
docs
```

Not sure if a comma-separated list, space-separated list, or a newline-separated list would be better.

cc @nbraud @astronouth7303 

Discussion:

Patch:
diff --git a/.pylintrc b/.pylintrc
index 4ebe076..d912ce6 100644
--- a/.pylintrc
+++ b/.pylintrc
@@ -10,10 +10,6 @@ load-plugins=pylint.extensions.check_elif,
              pylint.extensions.overlapping_exceptions,
              pylint.extensions.redefined_variable_type,
 
-# TODO: Should we do this? I mostly added it because of the number of errors
-#       when integrating it into pytest, since it seems to use . not ./emanate.
-ignore=test
-
 [MESSAGES CONTROL]
 
 # Enable the message, report, category or checker with the given id(s). You can
diff --git a/bork/api.py b/bork/api.py
index 6f1a5a7..bc6d353 100644
--- a/bork/api.py
+++ b/bork/api.py
@@ -19,6 +19,11 @@ DOWNLOAD_SOURCES = {
 }
 
 
+def aliases():
+    pyproject = toml.loads(Path("pyproject.toml").read_text())
+    return pyproject.get('tool', {}).get('bork', {}).get('aliases', {})
+
+
 def build():
     builder.dist()
     builder.zipapp()
diff --git a/bork/cli.py b/bork/cli.py
index 8494d67..f60dff6 100644
--- a/bork/cli.py
+++ b/bork/cli.py
@@ -19,6 +19,17 @@ def cli():
     pass
 
 
+@cli.command()
+def aliases():
+    alias_list = api.aliases()
+    if len(alias_list.keys()) == 0:
+        print("No aliases available.")
+        return
+
+    for key in alias_list.keys():
+        print(key)
+
+
 @cli.command()
 def build():
     api.build()
diff --git a/setup.cfg b/setup.cfg
index a8e4af4..64eaa99 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -62,4 +62,4 @@ exclude =
     dist,
     venv
 
-import-order-style = google
+import-order-style = pep8


Test patch:
diff --git a/tests/helpers.py b/tests/helpers.py
new file mode 100644
index 0000000..c1d6439
--- /dev/null
+++ b/tests/helpers.py
@@ -0,0 +1,7 @@
+from click.testing import CliRunner  # noqa: I202
+import bork.cli
+
+
+def bork_cli(*args):
+    runner = CliRunner()
+    return runner.invoke(bork.cli.cli, args)
diff --git a/tests/test_cmd_aliases.py b/tests/test_cmd_aliases.py
new file mode 100644
index 0000000..1f35e92
--- /dev/null
+++ b/tests/test_cmd_aliases.py
@@ -0,0 +1,7 @@
+from helpers import bork_cli
+
+
+def test_cmd_aliases():
+    result = bork_cli("aliases")
+    assert result.exit_code == 0
+    assert result.output == 'lint\ntest\n'