Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autocompletion of configure.py #357

Merged
merged 38 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
86b6acd
Add autocomplete related
ChunYen-Chen Sep 29, 2024
d640bfb
Let `-lh` be in alphabetical order
ChunYen-Chen Sep 29, 2024
a030aae
Update autocomplete wiki
ChunYen-Chen Sep 29, 2024
3b0c6d4
Add the verbose mode argument
ChunYen-Chen Nov 6, 2024
1afbd63
Merge branch 'autocomplete' of https://github.com/ChunYen-Chen/gamer-…
ChunYen-Chen Nov 6, 2024
8d65cc5
Merge branch 'hyschive:main' into autocomplete
ChunYen-Chen Nov 10, 2024
841bf3f
Merge remote-tracking branch 'gamer_ori/main' into autocomplete
ChunYen-Chen Nov 13, 2024
1cb430e
Merge branch 'master' into autocomplete
ChunYen-Chen Dec 11, 2024
f6ebfd9
Generalize prefix and suffix of simulation option
ChunYen-Chen Dec 11, 2024
c87ef93
Update wiki
ChunYen-Chen Dec 11, 2024
05692f1
Merge remote-tracking branch 'source/main' into autocomplete
ChunYen-Chen Dec 21, 2024
bc69ce0
Support option with `=` autocomplete
ChunYen-Chen Dec 26, 2024
958c189
Support `python configure.py` autocomplete
ChunYen-Chen Dec 28, 2024
fcfb1bf
Style
ChunYen-Chen Jan 15, 2025
fa8de22
Bugfix
ChunYen-Chen Jan 17, 2025
8c77e49
Bugfix
ChunYen-Chen Jan 17, 2025
78d60ff
Fix fallback issue: add trailing space back
technic960183 Jan 17, 2025
8a0d059
Merge pull request #8 from technic960183/357-fix-space
ChunYen-Chen Jan 19, 2025
ee2b899
Move validation to the top of the function
ChunYen-Chen Jan 21, 2025
3685e4d
Check the filename
ChunYen-Chen Jan 21, 2025
2b02e3c
Validate the executed file
ChunYen-Chen Jan 21, 2025
9d9b7df
Avoid long string
ChunYen-Chen Jan 21, 2025
3ee7433
Update wiki
ChunYen-Chen Jan 21, 2025
9f880de
Update wiki
ChunYen-Chen Jan 21, 2025
f8510be
Merge branch 'master' into autocomplete
ChunYen-Chen Jan 22, 2025
c667c4d
Fix wrong merge
ChunYen-Chen Jan 22, 2025
cb46325
Merge branch 'master' into autocomplete
ChunYen-Chen Jan 22, 2025
93a916a
Fix filename check
ChunYen-Chen Jan 23, 2025
aea74a7
chore(docs): Sync wiki to doc/wiki [skip-cd]
ChunYen-Chen Jan 23, 2025
eee01be
Apply suggestions from code review
ChunYen-Chen Feb 4, 2025
97c7c00
Remove prefix and suffix
ChunYen-Chen Feb 4, 2025
530e4e2
Update wiki
ChunYen-Chen Feb 4, 2025
728fc27
Update generate_make.sh
ChunYen-Chen Feb 4, 2025
2fd6853
Move the script
ChunYen-Chen Feb 4, 2025
3b3d51a
Update wiki
ChunYen-Chen Feb 4, 2025
96fe219
Update wiki
ChunYen-Chen Feb 4, 2025
b324df0
Minor
ChunYen-Chen Feb 4, 2025
deb46fa
Merge branch 'hyschive:main' into autocomplete
ChunYen-Chen Feb 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 45 additions & 5 deletions doc/wiki/Installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ e.g., `example/test_problem/Hydro/AcousticWave/generate_make.sh`.
make
```

If the compilation succeeds, you will see the following message
<pre>
Compiling GAMER --> Successful!
</pre>
and get an executable `gamer`, which will be automatically copied to `../bin/gamer`.

> [!TIP]
> To reduce the compilation time, you can perform a parallel
compilation by `make -j N`, where `N` is the number of compilation
Expand All @@ -59,8 +65,42 @@ invoke 4 compilation jobs simultaneously:
> However, please consult the documentation of your system to avoid
violating the usage policy.

If the compilation succeeds, you will see the following message
<pre>
Compiling GAMER --> Successful!
</pre>
and get an executable `gamer`, which will be automatically copied to `../bin/gamer`.

6. [Optional] Autocompletion of `configure.py`

Since there are too many options in GAMER, we introduce the autocomplete feature of `configure.py`. You can set the feature by the following steps:
1. Update the [shebang](https://en.wikipedia.org/wiki/Shebang_(Unix)) of `configure.py` if needed

For example, replace `#!/usr/bin/python3` with your `python` path.
<details>
<summary><u><i>top of configure.py</i></u></summary>
<pre>
#!/usr/bin/python3
"""
User guides of this script are provided in the following link.

https://github.com/gamer-project/gamer/wiki/Installation
"""
</pre>
</details>

2. Copy the autocomplete shell script to your `/home/usr` (`~`)
```bash
cp tool/bash/config_autocomplete.sh ~/
```

2. Update the `~/.bashrc` to load the autocomplete script

Please add the following line to `~/.bashrc`:
```bash
source ~/config_autocomplete.sh
```
NOTE: There are three commands registered in the `config_autocomplete.sh`, `python` `python3` and `./configure.py`.
If you would like to register your command, please add the command at the bottom of the script.

3. Reload `~/.bashrc` to enable the feature
```bash
source ~/.bashrc
```

Now, try to type `./configure.py` and then press `<tab>` multiple times!
11 changes: 10 additions & 1 deletion doc/wiki/configure.py.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,16 @@ Edit the section "source files" in the `Makefile_base` to add new source files.
)
```

4. [Optional] Add additional checks in `validation()` and warning messages in `warning()` under `Functions`.
4. [Optional] Add the common prefix/suffix of the simulation options. (Only works for string type)
```python
parser.add_argument( "--new_argument", type=str, metavar="STRING", gamer_name="NEW_SIMUALTION_OPTION", prefix="YOUR_PREFIX_", suffix="_YOUR_SUFFIX",
default="STR1", choice=["STR1", "STR2", "STR3"],
help="Your help message.\n"
)
```
The simulation option would be concatenated as `YOUR_PREFIX_STR1_YOUR_SUFFIX`.

5. [Optional] Add additional checks in `validation()` and warning messages in `warning()` under `Functions`.
* `validation()`

```python
Expand Down
2 changes: 1 addition & 1 deletion src/Makefile_base
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ EXECUTABLE := gamer

# output detailed compilation commands (0/1 = off/on)
#######################################################################################################
COMPILE_VERBOSE := 0
COMPILE_VERBOSE := @@@COMPILE_VERBOSE@@@



Expand Down
Loading