Skip to content

Commit cb1e3c2

Browse files
committed
updated --help command and LOGLIB env var purpose and effect
1 parent 02a7503 commit cb1e3c2

2 files changed

Lines changed: 24 additions & 11 deletions

File tree

HELP.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
- The tutorial circuit (`lesson1.lgf`) opens automatically for new users; open any other file with `./bin/analog file.lgf`.
88
- Default window size is 1280x960 (automatically saved and restored between sessions)
99
- To override, add to `~/.Xresources`: `mylib.geometry: 1600x1200+0+0`
10-
2. **Get command-line help**: `./bin/analog --help`
10+
2. **Get command-line help**: `./bin/analog --help` (use `--help`, not `-h`, as `-h` is used for home directory)
1111
3. **In-program help**: Press `?` key or click the HELP button
1212

1313
## Core Interaction Model
@@ -107,15 +107,15 @@ Use custom config: `./bin/analog -c log/lib/custom.cnf`
107107

108108
The `analog` command supports the following options:
109109

110-
- **`-h, --help`**: Show help message and exit
110+
- **`--help`**: Show help message and exit (use `--help`, not `-h`, as `-h` is used for home directory)
111+
- **`-h <dir>`**: Specify home directory for searching gate files, config files, etc. (default: `~/log` if not specified)
111112
- **`-c <file>`**: Specify configuration file (default: `analog.cnf` if not specified)
112113
- **`-v`**: Vanilla LOG mode (no CNF file loaded)
113114
- **`-x <display>`**: Specify X display name (e.g., `:0.0` or `hostname:0`)
114115
- **`-z [<file>]`**: Enable trace mode (debugging). If file is specified, trace output goes to that file (default: `trace.text`)
115116
- **`-d <file>`**: Specify dump file for debug output
116117
- **`-t <file>`**: Specify trace file for trace output (alternative to `-z <file>`)
117118
- **`-r <tool>`**: Run a specific tool immediately on startup (non-interactive mode)
118-
- **`-h <dir>`**: Specify home directory for searching gate files, config files, etc. (Note: conflicts with `-h` for help; use `--help` for help)
119119

120120
**Examples:**
121121
```bash
@@ -125,6 +125,7 @@ The `analog` command supports the following options:
125125
./bin/analog -v # Start without any configuration file
126126
./bin/analog -z trace.txt circuit.lgf # Enable trace mode with output file
127127
./bin/analog -x :1.0 # Use display :1.0
128+
./bin/analog -h ~/my_log_lib # Use custom home directory
128129
```
129130

130131
### How `-c` Option Works
@@ -140,7 +141,7 @@ According to the [official documentation](https://john-lazzaro.github.io/chipmun
140141
- LOG looks for a configuration file in this order:
141142
1. Program-specific name: `analog.cnf` (if running `analog`) or `diglog.cnf` (if running `diglog`)
142143
2. Fallback: `log.cnf`
143-
3. Search order: current directory → home directory (`~/log`) → `/lib/log` (or `$LOGLIB`)
144+
3. Search order: current directory → home directory (set by `-h <dir>`, default: `~/log`) → `$LOGLIB` directory (set by wrapper script to `log/lib` by default)
144145

145146
**Recommended approach for custom configurations:**
146147
To view a legacy design, it might be necessary to provide a custom .cnf file.
@@ -157,7 +158,7 @@ menu gate1 gate2 gate3 { Customize menu gates }
157158
**Note on INCLUDE paths:**
158159
- **Relative paths** (e.g., `genlog.cnf`) are resolved relative to the current working directory, which is `log/lib` after the wrapper script runs. This is the recommended approach.
159160
- **Absolute paths** (starting with `/`) will work but are not portable across systems (e.g., `/home/user/chipmunk/log/lib/genlog.cnf`).
160-
- Paths are searched in this order: current directory → launch directory → home directory (`~/log`) → LOGLIB directory (`log/lib`).
161+
- Paths are searched in this order: current directory → launch directory → home directory (set by `-h <dir>`, default: `~/log`) → `$LOGLIB` directory (set by wrapper script to `log/lib` by default).
161162

162163
**Note**: The wrapper script (`bin/analog`) automatically loads `analog.cnf` by default. To use a completely different configuration, specify it with `-c` or use `-v` for vanilla mode (no config file).
163164

@@ -171,6 +172,16 @@ These are set by the `bin/analog` wrapper script. You typically don't need to se
171172

172173
- **`CHIPMUNK_LAUNCH_DIR`**: Automatically set to your current working directory. Used to resolve relative file paths for `:load` and `:save` commands, ensuring files are loaded/saved relative to where you launched the program, not the internal working directory.
173174

175+
- **`LOGLIB`**: Automatically set to `${CHIPMUNK_DIR}/log/lib` by the wrapper script. This environment variable specifies the directory where LOG searches for configuration files (`.cnf` files) and gate library files. The wrapper script sets this automatically, but you can override it if needed:
176+
```bash
177+
# Use a custom library directory
178+
LOGLIB=/path/to/custom/lib ./bin/analog circuit.lgf
179+
```
180+
181+
**Note**: The `-h <dir>` command-line option sets the home directory (default: `~/log`) which is used for searching user-specific files, while `LOGLIB` specifies the library directory for system configuration and gate files. Both affect where LOG searches for files, but serve different purposes:
182+
- **`-h <dir>`**: User home directory for personal gate files and configurations (searched after current directory)
183+
- **`LOGLIB`**: System library directory for default configuration files and gate libraries (searched last in the path)
184+
174185
### Display Options
175186

176187
- **`CHIPMUNK_CURSOR_SCALE`**: Scale factor for Chipmunk's *bitmap* mouse cursors (1-4). Useful for high-DPI displays where the classic 16x16 cursors are too small. Default is 2 (2x normal size) when bitmap cursors are enabled.

bin/analog

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@ CHIPMUNK_DIR="$(cd "$(dirname "$0")/.." && pwd)"
66
export LOGLIB="${CHIPMUNK_DIR}/log/lib"
77
export CHIPMUNK_MODE=analog
88

9-
# Handle help options (check for --help or standalone -h, but not -h with argument)
10-
if [ "$1" = "--help" ] || ([ "$1" = "-h" ] && [ -z "$2" ]); then
9+
# Handle help option (only --help, not -h, so -h can be used for home directory)
10+
if [ "$1" = "--help" ]; then
1111
echo "Analog Circuit Simulator - Chipmunk Tools"
1212
echo ""
1313
echo "Usage:"
1414
echo " ./bin/analog [options] [circuit_file.lgf]"
1515
echo ""
1616
echo "Options:"
17-
echo " -h, --help Show this help message"
17+
echo " --help Show this help message"
18+
echo " -h <dir> Specify home directory for searching gate files, config files, etc."
1819
echo " -c <file> Specify configuration file (default: analog.cnf)"
1920
echo " -v Vanilla LOG mode (no CNF file)"
2021
echo " -x <display> Specify X display name (e.g., :0.0 or hostname:0)"
@@ -23,17 +24,18 @@ if [ "$1" = "--help" ] || ([ "$1" = "-h" ] && [ -z "$2" ]); then
2324
echo " -t <file> Specify trace file for trace output (alternative to -z)"
2425
echo " -r <tool> Run a specific tool immediately on startup (non-interactive)"
2526
echo ""
26-
echo "Note: -h is used for help in this wrapper. For home directory, use the"
27-
echo " underlying diglog command directly or set LOGLIB environment variable."
27+
echo "Note: The LOGLIB environment variable can also be used to specify the library"
28+
echo " directory for configuration files and gate libraries."
2829
echo ""
2930
echo "Examples:"
3031
echo " ./bin/analog # Start with lesson1.lgf (for beginners)"
3132
echo " ./bin/analog lessons/lesson1.lgf # Open a specific circuit file"
3233
echo " ./bin/analog -c log/lib/mos_example.cnf # Use custom configuration"
3334
echo " ./bin/analog -v # Start without configuration file"
3435
echo " ./bin/analog -z trace.txt circuit.lgf # Enable trace mode with output file"
36+
echo " ./bin/analog -h ~/my_log_lib # Use custom home directory"
3537
echo ""
36-
echo "For more information, see: https://john-lazzaro.github.io/chipmunk/document/log/index.html"
38+
echo "For more information, see: https://github.com/sensorsINI/chipmunk/blob/main/HELP.md"
3739
exit 0
3840
fi
3941

0 commit comments

Comments
 (0)