Skip to content

Commit

Permalink
Fix help message for --version
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamGagorik committed Aug 31, 2024
1 parent 8eab15f commit a3e7710
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
2 changes: 1 addition & 1 deletion docs/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ curl -LsSf https://astral.sh/uv/install.sh | sh
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
```

### Step 2: Test Run the bot
### Step 2: Run the app

```bash
git clone https://github.com/AdamGagorik/ffxiahbot.git
Expand Down
21 changes: 11 additions & 10 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ uv run ffxiahbot scrub

## Creating the Config File

You must create a YAML file to configure the tool (`config.yaml`).
All other options are passed as command line arguments.
You must create a YAML file to configure the tool (`config.yaml`). All other
options are passed as command line arguments.

```yaml
# ah
Expand All @@ -51,8 +51,8 @@ fail: true # fail on SQL database errors?
## Running the CLI
Simply run the `ffxiahbot` from the command line.
Specify the app you want to run and any flags you want to set.
Simply run the `ffxiahbot` from the command line. Specify the app you want to
run and any flags you want to set.

!!! warning

Expand All @@ -67,9 +67,9 @@ Specify the app you want to run and any flags you want to set.
The script will interact with the Auction House of a private Final Fantasy XI server.
╭─ Options ──────────────────────────────────────────────────────────────────────────────────────────────╮
│ --version Also show DEBUG messages.
│ --version Show version string.
│ --silent Only show ERROR messages. │
│ --verbose Enable verbose logging.
│ --verbose Also show DEBUG messages.
│ --logfile PATH The path to the log file. [default: ahbot.log] │
│ --disable-logfile Disable logging to a file. │
│ --help Show this message and exit. │
Expand Down Expand Up @@ -172,14 +172,15 @@ This command will download item data from ffxiah.com and save it to a CSV file.

#### Manually Editing the Items CSV

- Item data is stored in _items.csv_ (you can edit it with a text editor or Excel)
- Item data is stored in _items.csv_ (you can edit it with a text editor or
Excel)
- There is an already generated _items.csv_ in the bin folder for you

!!! warning

There is no reason to run the scrub app as an `items.csv` is included already in the repository!
You do not need to regenerate the database even if you think it is old!
You can cause yourself pricing issues, you have been warned!
- There is no reason to run the scrub app as an `items.csv` is included already in the repository!
- You do not need to regenerate the database even if you think it is old!
- You can cause yourself pricing issues, you have been warned!

!!! warning

Expand Down
16 changes: 11 additions & 5 deletions ffxiahbot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,19 @@
OptionalPath = Optional[Path]


app = Typer(add_completion=False, help=__doc__, invoke_without_command=True, rich_markup_mode="rich")
app = Typer(
add_completion=False,
help=__doc__,
invoke_without_command=True,
rich_markup_mode="rich",
)


@app.callback()
def setup(
version: Annotated[bool, Option("--version", help="Also show DEBUG messages.", is_eager=True)] = False,
version: Annotated[bool, Option("--version", help="Show version string.", is_eager=True)] = False,
silent: Annotated[bool, Option("--silent", help="Only show ERROR messages.")] = False,
verbose: Annotated[bool, Option("--verbose", help="Enable verbose logging.")] = False,
verbose: Annotated[bool, Option("--verbose", help="Also show DEBUG messages.")] = False,
logfile: Annotated[Path, Option(help="The path to the log file.")] = Path("ahbot.log"),
no_logfile: Annotated[bool, Option("--disable-logfile", help="Disable logging to a file.")] = False,
):
Expand All @@ -45,13 +50,14 @@ def setup(
file_handler = RotatingFileHandler(logfile, maxBytes=1048576 * 5, backupCount=5)
file_handler.setFormatter(
logging.Formatter(
"[%(asctime)s][%(processName)s][%(threadName)s][%(levelname)-5s]: %(message)s", "%Y-%m-%d %H:%M:%S"
"[%(asctime)s][%(processName)s][%(threadName)s][%(levelname)-5s]: %(message)s",
"%Y-%m-%d %H:%M:%S",
)
)
handlers = [RichHandler(), file_handler]

logging.basicConfig(
level=logging.DEBUG if verbose else logging.INFO if not silent else logging.ERROR,
level=(logging.DEBUG if verbose else logging.INFO if not silent else logging.ERROR),
format="%(message)s",
handlers=handlers,
)
Expand Down

0 comments on commit a3e7710

Please sign in to comment.