Skip to content

Commit

Permalink
feat: cli setup and config (#28)
Browse files Browse the repository at this point in the history
* style: Fix formatting to singlequotes in python
* chore(deps): Add platformdirs v4.2.2
* chore(deps): Add typing-extensions v4.12.2
* Setup Nexis CLI file structure
* Add configuration files for Nexis CLI
* chore: Bump Nexis 0.1.1 -> 0.2.0

---

Signed-off-by: AlexNg <[email protected]>
  • Loading branch information
caffeine-addictt authored Jul 26, 2024
2 parents 8bc408b + cca3f61 commit 6b0575d
Show file tree
Hide file tree
Showing 42 changed files with 1,419 additions and 35 deletions.
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ indent_style = tab
[*.py]
charset = utf-8
indent_size = 4
quote_type = double
13 changes: 10 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,18 @@ straightforward as possible.

### Added

- Improved API response handling ([#27](https://github.com/caffeine-addictt/nexis/pull/27))

### Changed

### Fixed
### Added

## v0.2.0 - 2024-07-24

### Added

- Improved API response handling ([#27](https://github.com/caffeine-addictt/nexis/pull/27))
- Add configuration files ([#28](https://github.com/caffeine-addictt/nexis/pull/28))
- Add CLI documentation ([#28](https://github.com/caffeine-addictt/nexis/pull/28))
- Add `nexis docs` command ([#28](https://github.com/caffeine-addictt/nexis/pull/28))

## v0.1.1 - 2024-07-23

Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<p align="center">
NYP InfoSec Auth Service
<br />
<a href="https://github.com/caffeine-addictt/nexis/docs/index.md">
<a href="https://github.com/caffeine-addictt/nexis/blob/main/docs/README.md">
<strong>Explore the docs »</strong>
</a>
<br />
Expand Down Expand Up @@ -79,9 +79,13 @@ pip install nexis
#### 2. Run Nexis

```sh
nexis
nexis --help
```

Read our [docs](./docs/README.md) for more information.

<p align="right">(<a href="#readme-top">back to top</a>)</p>

<!-- CONTRIBUTING -->

## Contributing
Expand Down
82 changes: 82 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Nexis CLI

Nexis is a powerful command-line (CLI) tool for
interacting with the Nexis (or your) API.

## Installation

You can install the CLI from the [Python Package Index](https://pypi.org/project/nexis/).
Simply install it with your preferred package manager:

```sh
pip install nexis
poetry add nexis
pipx install nexis
```

## Getting Started

After installing Nexis, you can run it from your terminal:

```sh
nexis [command] [options] [arguments]
```

To see a list of available commands, run:

```sh
nexis --help
```

## Usage

Running `Nexis` without any arguments will show you the help message.

```text
Usage:
command [options] [arguments]
Options:
-h, --help Display help for the given command.
-q, --quiet Do not output any message.
-V, --version Display this application version.
--ansi Force ANSI output.
--no-ansi Disable ANSI output.
-n, --no-interaction Do not ask any interactive question.
-D, --dev Use development options defined in nexis.toml.
-C, --config=CONFIG Use the specified configuration file.
-v|vv|vvv, --verbose Increase the verbosity of messages:
1 for normal output
2 for more verbose output
3 for debug.
Available commands:
help Display help for a command.
list List commands.
...
```

## Commands

Nexis comes with a variety of commands.
For detailed information on each command, refer to the
[Commands Documentation](./commands/README.md)

## Configuration

Nexis can be configured using the `nexis.toml` TOML file.
The configuration file load order is as follows:

1. `~/.config/nexis/nexis.toml`
2. `$CWD/nexis.toml`
3. Path from `-C/--config` option (if provided)

For detailed information on the configuration file,
refer to the [Configuration Documentation](./config.md)

## Closing

If you encounter any problems or have questions, please
feel free to [open an issue](https://github.com/caffeine-addictt/nexis/issues/new).
If you enjoy using Nexis, please consider [sponsoring us](https://github.com/sponsors/caffeine-addictt)
or giving us a [✨ star](https://github.com/caffeine-addictt/nexis/stargazers)!
49 changes: 49 additions & 0 deletions docs/commands/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Commands

This section describes the commands that `Nexis` supports.

## Global flags and options

Global flags and options can be used in any command.
Simply pass them to the command.

```sh
# For a shorthand flag
nexis -h

# For a longhand flag
nexis --help

# For a shorthand option
nexis -C nexis.toml

# For a longhand option
nexis --config nexis.toml
```

The difference between a flag and an option is that a flag takes no argument,
while an option takes an argument.

### Flags

- `-h, --help` - Show help for the command.
- `-q, --quiet` - Do not output anything.
- `-V, --version` - Show the installed version of the `Nexis.
- `--ansi` - Force ANSI output.
- `-n, --no-interaction` - Do not ask any interactive question.
- `-D, --dev` - When enabled, the command will be executed with development configuration.
- `-v, -vv, -vvv, --verbose` - Set the verbosity of the command.
1 `v` for normal output,
2 `v`'s for more verbose output and
3 `v`'s for debug.

### Options

- `-C, --config <file_path>` - Path to the configuration file to be loaded.

## List of commands

Click on the command names to view detailed documentation for each command.

- [docs](./docs.md)
- [list](./list.md)
29 changes: 29 additions & 0 deletions docs/commands/docs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# docs

Go to the documentation!

## Usage

Running this will open the docs in a new browser tab.

```sh
nexis docs [options]
```

## Options

- `-B, --browserless` - Providing this flag will not open the docs in your browser.

## Arguments

This command has no arguments.

## Examples

```sh
# Open the docs in a new browser tab
nexis docs

# Only print the URL
nexis docs -B
```
27 changes: 27 additions & 0 deletions docs/commands/list.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# list

List all the available commands.

## Usage

```sh
nexis list [options] [--] [<namespace>]
```

## Options

This command has no options.

## Arguments

- `namespace` (optional) The namespace to list.

## Examples

```sh
# Lists all the available commands
nexis list

# Lists all the available commands in `config`
nexis list config
```
36 changes: 36 additions & 0 deletions docs/config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Configutation

This section describes how to configure `Nexis`.

## Configuration File

`Nexis` uses TOML files for configuration.
The configuration file load order is:

1. `~/.config/nexis/nexis.toml`
2. `$CWD/nexis.toml`
3. Path from `-C/--config` option (if provided)

### `nexis.toml`

This is the default configuration used by `Nexis`.

```toml
mode = "dev"

[network]
api_url = "http://localhost:3000"

[development.network]
api_url = "http://localhost:3000"
```

## Customizing Configuration

The following options are available for `Nexis`:

- `mode`: `dev` or `prod` (default: `dev`)
- `version`: The version of Nexis to use (defaults to the local `Nexis` version)
- `network.api_url`: The base URL of the Nexis API (default: `http://localhost:3000`)
- `development.network.api_url`: The base URL of the Nexis API in development mode
(default: `http://localhost:3000`)
3 changes: 0 additions & 3 deletions docs/index.md

This file was deleted.

29 changes: 28 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "nexis"
version = "0.1.1"
version = "0.2.0"
description = "NYP InfoSec Auth CLI"
authors = ["Alex <[email protected]>"]
license = "GPL-3.0"
Expand Down Expand Up @@ -34,12 +34,14 @@ Source = "https://github.com/caffeine-addictt/nexis"
"Bug Tracker" = "https://github.com/caffeine-addictt/nexis/issues"

[tool.poetry.scripts]
nexis = "nexis.entrypoint:main"
nexis = "nexis.console.entrypoint:main"

[tool.poetry.dependencies]
python = "^3.9"
cleo = "^2.1.0"
importlib-metadata = { version = ">=4.4", python = "<3.10" }
typing-extensions = "^4.12.2"
platformdirs = "^4.2.2"

[tool.poetry.group.dev.dependencies]
pytest = "^8.3.1"
Expand Down
2 changes: 1 addition & 1 deletion ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ exclude = [

indent-style = "space"
line-ending = "lf"
quote-style = "single"
quote-style = "double"


[lint]
Expand Down
2 changes: 1 addition & 1 deletion src/nexis/__main__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sys


if __name__ == '__main__':
if __name__ == "__main__":
from nexis.entrypoint import main

sys.exit(main())
2 changes: 1 addition & 1 deletion src/nexis/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

from nexis.version import __version__

__all__ = ['__version__']
__all__ = ["__version__"]
Empty file added src/nexis/config/__init__.py
Empty file.
Loading

0 comments on commit 6b0575d

Please sign in to comment.