Skip to content

Commit

Permalink
📝 Update documentation for CLI and library usage
Browse files Browse the repository at this point in the history
- Reflect new subcommand structure in CLI docs
- Add sections for preset and layout management
- Update examples with new command syntax
- Revise library usage docs with new methods
- Expand error handling section with NotFoundError
  • Loading branch information
hyperb1iss committed Aug 20, 2024
1 parent 76851de commit 289b525
Show file tree
Hide file tree
Showing 5 changed files with 222 additions and 56 deletions.
60 changes: 43 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@
## ✨ Features
<a name="features"></a>

- 📋 List available lighting effects
- 📋 List available lighting effects and presets
- 🔍 Get detailed information about specific effects
- 🎨 Apply effects to your devices with ease
- 🎨 Apply effects and presets to your devices with ease
- 🖼️ Manage and switch between different layouts
- 🔆 Control brightness levels
- 🔌 Enable or disable the canvas
- 🖥️ User-friendly command-line interface
- 🖥️ User-friendly command-line interface with intuitive subcommands
- 🐍 Python client library for seamless integration into your projects
- 🔐 Error handling and connection management
- 🔄 Automatic effect caching for improved performance
Expand Down Expand Up @@ -52,38 +53,50 @@ This library uses the [SignalRGB REST API](https://docs.signalrgb.com/signalrgb-

### Command-line Interface

signalrgb-python comes with an intuitive command-line interface for easy interaction with your SignalRGB setup.
signalrgb-python comes with an intuitive command-line interface for easy interaction with your SignalRGB setup. The CLI now uses a subcommand structure for better organization and extensibility.

```bash
# List all available effects
signalrgb list-effects
signalrgb effect list

# Get details of a specific effect
signalrgb get-effect "Psychedelic Dream"
signalrgb effect "Psychedelic Dream"

# Apply an effect
signalrgb apply-effect "Rave Visualizer"
signalrgb effect apply "Rave Visualizer"

# List presets for the current effect
signalrgb preset list

# Apply a preset to the current effect
signalrgb preset apply "My Fancy Preset"

# List available layouts
signalrgb layout list

# Set the current layout
signalrgb layout set "My Gaming Layout"

# Get the current effect
signalrgb current-effect
signalrgb effect

# Set brightness level (0-100)
signalrgb brightness 75
signalrgb canvas brightness 75

# Get current brightness level
signalrgb brightness
signalrgb canvas brightness

# Enable the canvas
signalrgb enable
signalrgb canvas enable

# Disable the canvas
signalrgb disable
signalrgb canvas disable
```

You can also specify a custom host and port:

```bash
signalrgb --host hyperia.home --port 16038 list-effects
signalrgb --host hyperia.home --port 16038 effect list
```

For a full list of available commands and options, use:
Expand All @@ -110,9 +123,22 @@ for effect in effects:
# Apply an effect
client.apply_effect_by_name("Rain")

# Get current effect
# List presets for the current effect
current_effect = client.get_current_effect()
print(f"Current effect: {current_effect.attributes.name}")
presets = client.get_effect_presets(current_effect.id)
for preset in presets:
print(f"Preset: {preset.id}")

# Apply a preset
client.apply_effect_preset(current_effect.id, "Cool Preset")

# Get available layouts
layouts = client.get_layouts()
for layout in layouts:
print(f"Layout: {layout.id}")

# Set the current layout
client.current_layout = "Gaming Setup"

# Control brightness
client.brightness = 50
Expand All @@ -128,15 +154,15 @@ print(f"Canvas enabled: {client.enabled}")
The client provides custom exceptions for different types of errors:

```python
from signalrgb.client import SignalRGBClient, ConnectionError, APIError, EffectNotFoundError
from signalrgb.client import SignalRGBClient, ConnectionError, APIError, NotFoundError

client = SignalRGBClient()

try:
client.apply_effect_by_name("Non-existent Effect")
except ConnectionError as e:
print(f"Connection failed: {e}")
except EffectNotFoundError as e:
except NotFoundError as e:
print(f"Effect not found: {e}")
except APIError as e:
print(f"API error occurred: {e}")
Expand Down
2 changes: 1 addition & 1 deletion docs/api/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ The SignalRGB client defines several custom exceptions for error handling:
show_root_heading: true
show_source: true

::: signalrgb.client.EffectNotFoundError
::: signalrgb.client.NotFoundError
options:
show_root_heading: true
show_source: true
Expand Down
22 changes: 18 additions & 4 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ Welcome to the documentation for signalrgb-python. This library provides a power

## Features

- 📋 List available lighting effects
- 📋 List available lighting effects and presets
- 🔍 Get detailed information about specific effects
- 🎨 Apply effects to your devices with ease
- 🎨 Apply effects and presets to your devices with ease
- 🖼️ Manage and switch between different layouts
- 🔆 Control brightness levels
- 🔌 Enable or disable the canvas
- 🖥️ User-friendly command-line interface
- 🖥️ User-friendly command-line interface with intuitive subcommands
- 🐍 Python client library for seamless integration into your projects
- 🔐 Error handling and connection management
- 🔄 Automatic effect caching for improved performance
Expand All @@ -25,7 +26,7 @@ pip install signalrgb
Use the CLI to list available effects:

```bash
signalrgb list-effects
signalrgb effect list
```

Or use the Python library in your code:
Expand All @@ -45,6 +46,19 @@ print(f"Current brightness: {client.brightness}")
# Enable/disable the canvas
client.enabled = True
print(f"Canvas enabled: {client.enabled}")

# List and apply presets
current_effect = client.get_current_effect()
presets = client.get_effect_presets(current_effect.id)
for preset in presets:
print(f"Preset: {preset.id}")
client.apply_effect_preset(current_effect.id, presets[0].id)

# Manage layouts
layouts = client.get_layouts()
for layout in layouts:
print(f"Layout: {layout.id}")
client.current_layout = layouts[0].id
```

For more detailed information, check out the [Installation](installation.md) and [Usage](usage/cli.md) guides.
95 changes: 74 additions & 21 deletions docs/usage/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ signalrgb-python provides a user-friendly command-line interface for interacting
The basic syntax for using the SignalRGB CLI is:

```bash
signalrgb [OPTIONS] COMMAND [ARGS]...
signalrgb [OPTIONS] COMMAND [SUBCOMMAND] [ARGS]...
```

You can always use the `--help` option to get more information about available commands and options:
Expand All @@ -18,74 +18,114 @@ signalrgb --help

## Available Commands

### List Effects
### Effect Commands

#### List Effects

To list all available lighting effects:

```bash
signalrgb list-effects
signalrgb effect list
```

### Get Effect Details
#### Get Effect Details

To get detailed information about a specific effect:

```bash
signalrgb get-effect "Effect Name"
signalrgb effect "Effect Name"
```

Replace "Effect Name" with the name of the effect you want to inspect.

### Apply an Effect
#### Apply an Effect

To apply a specific effect:

```bash
signalrgb apply-effect "Effect Name"
signalrgb effect apply "Effect Name"
```

### Get Current Effect
#### Get Current Effect

To see which effect is currently active:

```bash
signalrgb current-effect
signalrgb effect
```

### Preset Commands

#### List Presets

To list presets for the current effect:

```bash
signalrgb preset list
```

#### Apply a Preset

To apply a preset to the current effect:

```bash
signalrgb preset apply "Preset Name"
```

### Layout Commands

#### List Layouts

To list all available layouts:

```bash
signalrgb layout list
```

#### Set Current Layout

To set the current layout:

```bash
signalrgb layout set "Layout Name"
```

### Control Brightness
### Canvas Commands

#### Control Brightness

To set the brightness level (0-100):

```bash
signalrgb brightness 75
signalrgb canvas brightness 75
```

To get the current brightness level:

```bash
signalrgb brightness
signalrgb canvas brightness
```

### Enable/Disable Canvas
#### Enable/Disable Canvas

To enable the canvas:

```bash
signalrgb enable
signalrgb canvas enable
```

To disable the canvas:

```bash
signalrgb disable
signalrgb canvas disable
```

## Global Options

You can specify a custom host and port for all commands:

```bash
signalrgb --host my-pc.local --port 16038 list-effects
signalrgb --host my-pc.local --port 16038 effect list
```

## Examples
Expand All @@ -95,31 +135,44 @@ Here are some example use cases:
1. List all effects and pipe the output to `grep` to find a specific effect:

```bash
signalrgb list-effects | grep "Electric Space"
signalrgb effect list | grep "Electric Space"
```

2. Apply the "Rave Visualizer" effect:

```bash
signalrgb apply-effect "Rave Visualizer"
signalrgb effect apply "Rave Visualizer"
```

3. Get details of the current effect and save it to a file:

```bash
signalrgb current-effect > current_effect.txt
signalrgb effect > current_effect.txt
```

4. Set the brightness to 50%:

```bash
signalrgb brightness 50
signalrgb canvas brightness 50
```

5. Enable the canvas:

```bash
signalrgb enable
signalrgb canvas enable
```

6. List and apply a preset:

```bash
signalrgb preset list
signalrgb preset apply "Cool Preset"
```

7. Switch to a different layout:

```bash
signalrgb layout set "Gaming Setup"
```

Remember to refer to the `--help` option for each command to see all available options and arguments.
Loading

0 comments on commit 289b525

Please sign in to comment.