Skip to content

Commit 18af51a

Browse files
authored
fix: more fixes/improvements (MODFLOW-ORG#283)
* add commands for models and programs CLIs, with root mf namespace * add : interactive bindir prompt like flopy's get-modflow, with similar options * fix exe path resolution
1 parent a958401 commit 18af51a

9 files changed

Lines changed: 571 additions & 133 deletions

File tree

docs/md/dev/models.md

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -337,36 +337,36 @@ The simplest approach would be a single such script/command, e.g. `python -m mod
337337

338338
```bash
339339
# Show configured registries and status
340-
python -m modflow_devtools.models info
340+
mf models info
341341

342342
# Sync all sources to configured refs
343-
python -m modflow_devtools.models sync
343+
mf models sync
344344

345345
# Force re-download even if cached
346-
python -m modflow_devtools.models sync --force
346+
mf models sync --force
347347

348348
# For a repo publishing models via releases
349-
python -m modflow_devtools.models sync --repo MODFLOW-ORG/modflow6-examples --ref current
349+
mf models sync --repo MODFLOW-ORG/modflow6-examples --ref current
350350

351351
# For a repo with models under version control
352-
python -m modflow_devtools.models sync --repo MODFLOW-ORG/modflow6-testmodels --ref develop
353-
python -m modflow_devtools.models sync --repo MODFLOW-ORG/modflow6-testmodels --ref f3df630 # commit hash works too
354-
```
355-
356-
Or via CLI commands:
357-
358-
```bash
359-
models info
360-
models sync
352+
mf models sync --repo MODFLOW-ORG/modflow6-testmodels --ref develop
353+
mf models sync --repo MODFLOW-ORG/modflow6-testmodels --ref f3df630 # commit hash works too
361354
```
362355

363-
Perhaps leading with a `models` command namespace is too generic, and we need e.g. a leading `mf` namespace on all commands exposed by `modflow-devtools`:
356+
CLI commands are available in two forms:
364357

365358
```bash
359+
# Using the mf namespace (shorter)
366360
mf models info
367361
mf models sync
362+
363+
# Or using the module form
364+
python -m modflow_devtools.models info
365+
python -m modflow_devtools.models sync
368366
```
369367

368+
The `mf` command provides a unified CLI namespace for all `modflow-devtools` commands.
369+
370370
#### Automatic sync
371371

372372
At install time, `modflow-devtools` can load the bootstrap file and attempt to sync to all configured repositories/registries. The install should not fail if registry sync fails (due either to network errors or misconfiguration), however — an informative warning can be shown, and sync retried on subsequent imports and/or manually (see below).
@@ -709,7 +709,7 @@ _DEFAULT_CACHE.clear()
709709
#### Show Registry Status
710710

711711
```bash
712-
$ python -m modflow_devtools.models info
712+
$ mf models info
713713

714714
Registry sync status:
715715

@@ -727,19 +727,19 @@ mf6/example (MODFLOW-ORG/modflow6-examples)
727727

728728
```bash
729729
# Sync all configured sources/refs
730-
$ python -m modflow_devtools.models sync
730+
$ mf models sync
731731

732732
# Sync specific source
733-
$ python -m modflow_devtools.models sync --source modflow6-testmodels
733+
$ mf models sync --source modflow6-testmodels
734734

735735
# Sync specific ref
736-
$ python -m modflow_devtools.models sync --source modflow6-testmodels --ref develop
736+
$ mf models sync --source modflow6-testmodels --ref develop
737737

738738
# Force re-download
739-
$ python -m modflow_devtools.models sync --force
739+
$ mf models sync --force
740740

741741
# Test against a fork
742-
$ python -m modflow_devtools.models sync \
742+
$ mf models sync \
743743
--source modflow6-testmodels \
744744
--ref feature-branch \
745745
--repo myusername/modflow6-testmodels
@@ -749,19 +749,19 @@ $ python -m modflow_devtools.models sync \
749749

750750
```bash
751751
# Summary view
752-
$ python -m modflow_devtools.models list
752+
$ mf models list
753753

754754
# Verbose view (show all model names)
755-
$ python -m modflow_devtools.models list --verbose
755+
$ mf models list --verbose
756756

757757
# Filter by source
758-
$ python -m modflow_devtools.models list --source mf6/test
758+
$ mf models list --source mf6/test
759759

760760
# Filter by ref
761-
$ python -m modflow_devtools.models list --ref registry
761+
$ mf models list --ref registry
762762

763763
# Combine filters
764-
$ python -m modflow_devtools.models list --source mf6/test --ref registry --verbose
764+
$ mf models list --source mf6/test --ref registry --verbose
765765
```
766766

767767
### Registry Creation Tool

docs/md/dev/programs.md

Lines changed: 30 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -481,19 +481,19 @@ Exposed as a CLI command and Python API:
481481

482482
```bash
483483
# Sync all configured sources and release tags
484-
python -m modflow_devtools.programs sync
484+
mf programs sync
485485

486-
# Sync specific source to specific release version
487-
python -m modflow_devtools.programs sync --repo MODFLOW-ORG/modflow6 --version 6.6.3
486+
# Sync specific source
487+
mf programs sync --source modflow6
488488

489489
# Force re-download
490-
python -m modflow_devtools.programs sync --force
490+
mf programs sync --force
491491

492492
# Show sync status
493-
python -m modflow_devtools.programs info
493+
mf programs info
494494

495495
# List available programs
496-
python -m modflow_devtools.programs list
496+
mf programs list
497497
```
498498

499499
Or via Python API:
@@ -544,15 +544,15 @@ The `--force` flag has different meanings depending on the command, maintaining
544544
**Common patterns**:
545545
```bash
546546
# Update to latest registry and install
547-
python -m modflow_devtools.programs sync --force
548-
python -m modflow_devtools.programs install mf6
547+
mf programs sync --force
548+
mf programs install mf6
549549

550550
# Repair installation without touching registry (offline-friendly)
551-
python -m modflow_devtools.programs install mf6 --force
551+
mf programs install mf6 --force
552552

553553
# Complete refresh of both metadata and installation
554-
python -m modflow_devtools.programs sync --force
555-
python -m modflow_devtools.programs install mf6 --force
554+
mf programs sync --force
555+
mf programs install mf6 --force
556556
```
557557

558558
### Program installation
@@ -561,38 +561,27 @@ Installation extends beyond metadata to actually providing program executables b
561561

562562
```bash
563563
# Install from binary (auto-detects platform)
564-
python -m modflow_devtools.programs install mf6
564+
mf programs install mf6
565565

566566
# Install specific version
567-
python -m modflow_devtools.programs install mf6@6.6.3
567+
mf programs install mf6@6.6.3
568568

569-
# Install to custom location (interactive selection like get-modflow)
570-
python -m modflow_devtools.programs install mf6 --bindir :
571-
572-
# Install to specific directory
573-
python -m modflow_devtools.programs install mf6 --bindir /usr/local/bin
569+
# Install to custom location
570+
mf programs install mf6 --bindir /usr/local/bin
574571

575572
# Install multiple versions side-by-side (cached separately)
576-
python -m modflow_devtools.programs install mf6@6.6.3
577-
python -m modflow_devtools.programs install mf6@6.5.0
578-
579-
# Select active version (re-copies from cache to bindir)
580-
python -m modflow_devtools.programs select mf6@6.6.3
581-
582-
# List installed programs
583-
python -m modflow_devtools.programs list --installed
584-
585-
# List available versions of a program
586-
python -m modflow_devtools.programs list mf6
573+
mf programs install mf6@6.6.3
574+
mf programs install mf6@6.5.0
587575

588-
# Show where program is installed
589-
python -m modflow_devtools.programs which mf6
576+
# List installation history
577+
mf programs history
578+
mf programs history mf6
590579

591580
# Uninstall specific version
592-
python -m modflow_devtools.programs uninstall mf6@6.6.3
581+
mf programs uninstall mf6@6.6.3
593582

594583
# Uninstall all versions
595-
python -m modflow_devtools.programs uninstall mf6 --all
584+
mf programs uninstall mf6 --all
596585
```
597586

598587
Python API:
@@ -1055,14 +1044,14 @@ The Programs API has been implemented following a consolidated object-oriented a
10551044
- Force re-download support
10561045

10571046
**CLI Interface**
1058-
- `python -m modflow_devtools.programs sync` - Sync registries
1059-
- `python -m modflow_devtools.programs info` - Show sync status
1060-
- `python -m modflow_devtools.programs list` - List available programs
1061-
- `python -m modflow_devtools.programs install` - Install a program
1062-
- `python -m modflow_devtools.programs select` - Switch active version
1063-
- `python -m modflow_devtools.programs uninstall` - Uninstall a program
1064-
- `python -m modflow_devtools.programs which` - Show executable path
1065-
- `python -m modflow_devtools.programs installed` - List installed programs
1047+
- `mf programs sync` - Sync registries
1048+
- `mf programs info` - Show sync status
1049+
- `mf programs list` - List available programs
1050+
- `mf programs install` - Install a program
1051+
- `mf programs uninstall` - Uninstall a program
1052+
- `mf programs history` - Show installation history
1053+
1054+
All commands also support the module form: `python -m modflow_devtools.programs <command>`
10661055

10671056
**Registry Generation Tool**
10681057
- `modflow_devtools/programs/make_registry.py` - Generate registry files

docs/md/models.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,16 @@ for source_name, source_status in status.items():
7777
print(f"{source_name}: {source_status.cached_refs}")
7878
```
7979

80-
Or via CLI:
80+
Or via CLI (both forms are equivalent):
8181

8282
```bash
83+
# Using the mf command
84+
mf models sync
85+
mf models sync --source modflow6-testmodels
86+
mf models sync --source modflow6-testmodels --ref develop
87+
mf models sync --force
88+
89+
# Or using the module form
8390
python -m modflow_devtools.models sync
8491
python -m modflow_devtools.models sync --source modflow6-testmodels
8592
python -m modflow_devtools.models sync --source modflow6-testmodels --ref develop
@@ -101,10 +108,17 @@ for example_name, model_list in list(examples.items())[:3]:
101108
print(f"{example_name}: {len(model_list)} models")
102109
```
103110

104-
Or by CLI:
111+
Or by CLI (both forms are equivalent):
105112

106113
```bash
114+
# Using the mf command
115+
mf models info # Show sync status
116+
mf models list # Show model summary...
117+
mf models list --verbose # ..or full list
118+
# Filter by source
119+
mf models list --source mf6/test --verbose
107120

121+
# Or using the module form
108122
python -m modflow_devtools.models info # Show sync status
109123
python -m modflow_devtools.models list # Show model summary...
110124
python -m modflow_devtools.models list --verbose # ..or full list
@@ -268,7 +282,8 @@ export MODFLOW_DEVTOOLS_NO_AUTO_SYNC=1
268282
Then manually sync when needed:
269283

270284
```bash
271-
python -m modflow_devtools.models sync
285+
mf models sync
286+
# Or: python -m modflow_devtools.models sync
272287
```
273288

274289
## Repository Integration

0 commit comments

Comments
 (0)