stata-cli 0.5.0__tar.gz → 0.5.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {stata_cli-0.5.0 → stata_cli-0.5.2}/PKG-INFO +23 -3
- {stata_cli-0.5.0 → stata_cli-0.5.2}/README.md +22 -2
- {stata_cli-0.5.0 → stata_cli-0.5.2}/pyproject.toml +1 -1
- stata_cli-0.5.2/src/stata_cli/__init__.py +1 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/daemon.py +2 -1
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/main.py +52 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/utils.py +60 -6
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli.egg-info/PKG-INFO +23 -3
- stata_cli-0.5.0/src/stata_cli/__init__.py +0 -1
- {stata_cli-0.5.0 → stata_cli-0.5.2}/setup.cfg +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/__main__.py +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/engine.py +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/graph_artifacts.py +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/output_filter.py +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skill_registry.py +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/overview.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/packages/asdoc.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/packages/binsreg.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/packages/coefplot.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/packages/data-manipulation.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/packages/diagnostics.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/packages/did.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/packages/estout.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/packages/event-study.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/packages/graph-schemes.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/packages/ivreg2.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/packages/nprobust.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/packages/outreg2.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/packages/package-management.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/packages/psmatch2.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/packages/rdrobust.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/packages/reghdfe.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/packages/synth.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/packages/tabout.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/packages/winsor.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/packages/xtabond2.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/references/advanced-programming.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/references/basics-getting-started.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/references/bootstrap-simulation.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/references/data-import-export.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/references/data-management.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/references/date-time-functions.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/references/descriptive-statistics.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/references/difference-in-differences.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/references/external-tools-integration.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/references/gmm-estimation.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/references/graphics.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/references/limited-dependent-variables.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/references/linear-regression.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/references/machine-learning.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/references/mata-data-access.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/references/mata-introduction.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/references/mata-matrix-operations.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/references/mata-programming.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/references/matching-methods.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/references/mathematical-functions.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/references/maximum-likelihood.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/references/missing-data-handling.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/references/nonparametric-methods.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/references/panel-data.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/references/programming-basics.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/references/regression-discontinuity.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/references/sample-selection.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/references/sem-factor-analysis.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/references/spatial-analysis.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/references/string-functions.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/references/survey-data-analysis.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/references/survival-analysis.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/references/tables-reporting.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/references/time-series.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/references/treatment-effects.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/references/variables-operators.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/references/workflow-best-practices.md +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/smcl_parser.py +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli.egg-info/SOURCES.txt +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli.egg-info/dependency_links.txt +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli.egg-info/entry_points.txt +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli.egg-info/requires.txt +0 -0
- {stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: stata-cli
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.2
|
|
4
4
|
Summary: Command-line interface for running Stata commands via PyStata
|
|
5
5
|
License: MIT
|
|
6
6
|
Keywords: stata,cli,statistics,data-science
|
|
@@ -51,7 +51,7 @@ A command-line interface for [Stata](https://www.stata.com/) via PyStata — bui
|
|
|
51
51
|
| **Frame Management** | List Stata frames and current working frame via `frame` |
|
|
52
52
|
| **Help System** | Browse Stata help topics with SMCL-to-plain-text conversion |
|
|
53
53
|
| **Graph Export** | Auto-detect and export graphs as PNG/SVG/PDF to `~/.stata-cli/graphs/` |
|
|
54
|
-
| **Daemon Mode** | Persistent background process for sub-second execution via
|
|
54
|
+
| **Daemon Mode** | Persistent background process for sub-second execution; parallel sessions via `--session` |
|
|
55
55
|
| **Output Control** | Compact mode, JSON output, token limit management, log file output |
|
|
56
56
|
| **Interruption** | Send break signal to stop long-running commands |
|
|
57
57
|
| **Skill Library** | Built-in Stata reference with 57 topics: syntax, econometrics, causal inference, packages |
|
|
@@ -290,13 +290,32 @@ stata-cli daemon stop # Shut down
|
|
|
290
290
|
|---------|-------------|
|
|
291
291
|
| `daemon start` | Start the background daemon process |
|
|
292
292
|
| `daemon stop` | Graceful shutdown |
|
|
293
|
-
| `daemon
|
|
293
|
+
| `daemon stop --all` | Stop all running sessions |
|
|
294
|
+
| `daemon status` | Show all running sessions (PID, uptime, idle) |
|
|
294
295
|
| `daemon restart` | Stop + start (clean Stata state) |
|
|
295
296
|
|
|
296
297
|
Commands auto-route through the daemon when it is running. Use `--no-daemon` to force direct execution.
|
|
297
298
|
|
|
298
299
|
The daemon auto-shuts down after 1 hour of inactivity (configurable with `--idle-timeout`).
|
|
299
300
|
|
|
301
|
+
### Parallel Sessions
|
|
302
|
+
|
|
303
|
+
Run multiple independent Stata instances — like opening multiple Stata windows:
|
|
304
|
+
|
|
305
|
+
```bash
|
|
306
|
+
# Start named sessions
|
|
307
|
+
stata-cli --session proj_a daemon start
|
|
308
|
+
stata-cli --session proj_b daemon start
|
|
309
|
+
|
|
310
|
+
# Each session has its own data, estimates, and macros
|
|
311
|
+
stata-cli --session proj_a run "use project_a.dta, clear"
|
|
312
|
+
stata-cli --session proj_b run "use project_b.dta, clear"
|
|
313
|
+
|
|
314
|
+
# Route any command to a specific session
|
|
315
|
+
stata-cli --session proj_a run "regress price mpg weight"
|
|
316
|
+
stata-cli --session proj_b return e
|
|
317
|
+
```
|
|
318
|
+
|
|
300
319
|
## Advanced Usage
|
|
301
320
|
|
|
302
321
|
### Global Options
|
|
@@ -305,6 +324,7 @@ The daemon auto-shuts down after 1 hour of inactivity (configurable with `--idle
|
|
|
305
324
|
|--------|-------------|---------|
|
|
306
325
|
| `--stata-path PATH` | Stata installation directory | auto-detected |
|
|
307
326
|
| `--edition [mp\|se\|be]` | Stata edition | `mp` |
|
|
327
|
+
| `--session NAME` | Daemon session name (for parallel sessions) | `default` |
|
|
308
328
|
| `--compact` | Strip verbose output noise | off |
|
|
309
329
|
| `--json` | Structured JSON output | off |
|
|
310
330
|
| `--timeout SECONDS` | Execution timeout | 600 |
|
|
@@ -38,7 +38,7 @@ A command-line interface for [Stata](https://www.stata.com/) via PyStata — bui
|
|
|
38
38
|
| **Frame Management** | List Stata frames and current working frame via `frame` |
|
|
39
39
|
| **Help System** | Browse Stata help topics with SMCL-to-plain-text conversion |
|
|
40
40
|
| **Graph Export** | Auto-detect and export graphs as PNG/SVG/PDF to `~/.stata-cli/graphs/` |
|
|
41
|
-
| **Daemon Mode** | Persistent background process for sub-second execution via
|
|
41
|
+
| **Daemon Mode** | Persistent background process for sub-second execution; parallel sessions via `--session` |
|
|
42
42
|
| **Output Control** | Compact mode, JSON output, token limit management, log file output |
|
|
43
43
|
| **Interruption** | Send break signal to stop long-running commands |
|
|
44
44
|
| **Skill Library** | Built-in Stata reference with 57 topics: syntax, econometrics, causal inference, packages |
|
|
@@ -277,13 +277,32 @@ stata-cli daemon stop # Shut down
|
|
|
277
277
|
|---------|-------------|
|
|
278
278
|
| `daemon start` | Start the background daemon process |
|
|
279
279
|
| `daemon stop` | Graceful shutdown |
|
|
280
|
-
| `daemon
|
|
280
|
+
| `daemon stop --all` | Stop all running sessions |
|
|
281
|
+
| `daemon status` | Show all running sessions (PID, uptime, idle) |
|
|
281
282
|
| `daemon restart` | Stop + start (clean Stata state) |
|
|
282
283
|
|
|
283
284
|
Commands auto-route through the daemon when it is running. Use `--no-daemon` to force direct execution.
|
|
284
285
|
|
|
285
286
|
The daemon auto-shuts down after 1 hour of inactivity (configurable with `--idle-timeout`).
|
|
286
287
|
|
|
288
|
+
### Parallel Sessions
|
|
289
|
+
|
|
290
|
+
Run multiple independent Stata instances — like opening multiple Stata windows:
|
|
291
|
+
|
|
292
|
+
```bash
|
|
293
|
+
# Start named sessions
|
|
294
|
+
stata-cli --session proj_a daemon start
|
|
295
|
+
stata-cli --session proj_b daemon start
|
|
296
|
+
|
|
297
|
+
# Each session has its own data, estimates, and macros
|
|
298
|
+
stata-cli --session proj_a run "use project_a.dta, clear"
|
|
299
|
+
stata-cli --session proj_b run "use project_b.dta, clear"
|
|
300
|
+
|
|
301
|
+
# Route any command to a specific session
|
|
302
|
+
stata-cli --session proj_a run "regress price mpg weight"
|
|
303
|
+
stata-cli --session proj_b return e
|
|
304
|
+
```
|
|
305
|
+
|
|
287
306
|
## Advanced Usage
|
|
288
307
|
|
|
289
308
|
### Global Options
|
|
@@ -292,6 +311,7 @@ The daemon auto-shuts down after 1 hour of inactivity (configurable with `--idle
|
|
|
292
311
|
|--------|-------------|---------|
|
|
293
312
|
| `--stata-path PATH` | Stata installation directory | auto-detected |
|
|
294
313
|
| `--edition [mp\|se\|be]` | Stata edition | `mp` |
|
|
314
|
+
| `--session NAME` | Daemon session name (for parallel sessions) | `default` |
|
|
295
315
|
| `--compact` | Strip verbose output noise | off |
|
|
296
316
|
| `--json` | Structured JSON output | off |
|
|
297
317
|
| `--timeout SECONDS` | Execution timeout | 600 |
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.5.2"
|
|
@@ -137,12 +137,13 @@ class DaemonServer:
|
|
|
137
137
|
@staticmethod
|
|
138
138
|
def _find_free_port() -> int:
|
|
139
139
|
for port in range(_DEFAULT_PORT, _DEFAULT_PORT + 200):
|
|
140
|
+
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
140
141
|
try:
|
|
141
|
-
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
142
142
|
s.bind(("127.0.0.1", port))
|
|
143
143
|
s.close()
|
|
144
144
|
return port
|
|
145
145
|
except OSError:
|
|
146
|
+
s.close()
|
|
146
147
|
continue
|
|
147
148
|
raise RuntimeError("No free port found")
|
|
148
149
|
|
|
@@ -447,6 +447,58 @@ def skill_cmd(ctx, topic, list_topics):
|
|
|
447
447
|
click.echo(content)
|
|
448
448
|
|
|
449
449
|
|
|
450
|
+
# ── Config subcommands ──────────────────────────────────────────────────
|
|
451
|
+
|
|
452
|
+
@cli.group("config")
|
|
453
|
+
def config_cmd():
|
|
454
|
+
"""Manage stata-cli configuration (~/.stata-cli/config.json)."""
|
|
455
|
+
|
|
456
|
+
|
|
457
|
+
@config_cmd.command("set")
|
|
458
|
+
@click.argument("key")
|
|
459
|
+
@click.argument("value")
|
|
460
|
+
def config_set(key, value):
|
|
461
|
+
"""Set a configuration value.
|
|
462
|
+
|
|
463
|
+
\b
|
|
464
|
+
Examples:
|
|
465
|
+
stata-cli config set stata-path "/usr/local/stata19"
|
|
466
|
+
stata-cli config set edition se
|
|
467
|
+
"""
|
|
468
|
+
from .utils import set_config
|
|
469
|
+
set_config(key, value)
|
|
470
|
+
click.echo(f"{key} = {value}")
|
|
471
|
+
|
|
472
|
+
|
|
473
|
+
@config_cmd.command("get")
|
|
474
|
+
@click.argument("key")
|
|
475
|
+
def config_get(key):
|
|
476
|
+
"""Get a configuration value.
|
|
477
|
+
|
|
478
|
+
\b
|
|
479
|
+
Examples:
|
|
480
|
+
stata-cli config get stata-path
|
|
481
|
+
"""
|
|
482
|
+
from .utils import get_config
|
|
483
|
+
value = get_config(key)
|
|
484
|
+
if value is None:
|
|
485
|
+
click.echo(f"{key}: (not set)")
|
|
486
|
+
else:
|
|
487
|
+
click.echo(f"{key} = {value}")
|
|
488
|
+
|
|
489
|
+
|
|
490
|
+
@config_cmd.command("list")
|
|
491
|
+
def config_list():
|
|
492
|
+
"""Show all configuration values."""
|
|
493
|
+
from .utils import get_all_config
|
|
494
|
+
data = get_all_config()
|
|
495
|
+
if not data:
|
|
496
|
+
click.echo("No configuration set. Use 'stata-cli config set <key> <value>' to configure.")
|
|
497
|
+
return
|
|
498
|
+
for k, v in data.items():
|
|
499
|
+
click.echo(f"{k} = {v}")
|
|
500
|
+
|
|
501
|
+
|
|
450
502
|
# ── Daemon subcommands ───────────────────────────────────────────────────
|
|
451
503
|
|
|
452
504
|
@cli.group()
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"""Platform detection and Stata path auto-discovery."""
|
|
2
2
|
from __future__ import annotations
|
|
3
3
|
|
|
4
|
+
import json
|
|
4
5
|
import os
|
|
5
6
|
import platform
|
|
6
7
|
|
|
@@ -10,37 +11,90 @@ IS_WINDOWS = PLATFORM == "Windows"
|
|
|
10
11
|
IS_MACOS = PLATFORM == "Darwin"
|
|
11
12
|
IS_LINUX = PLATFORM == "Linux"
|
|
12
13
|
|
|
14
|
+
_CONFIG_DIR = os.path.join(os.path.expanduser("~"), ".stata-cli")
|
|
15
|
+
_CONFIG_FILE = os.path.join(_CONFIG_DIR, "config.json")
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def get_config(key: str) -> str | None:
|
|
19
|
+
"""Read a value from ~/.stata-cli/config.json."""
|
|
20
|
+
if not os.path.isfile(_CONFIG_FILE):
|
|
21
|
+
return None
|
|
22
|
+
try:
|
|
23
|
+
with open(_CONFIG_FILE, encoding="utf-8") as f:
|
|
24
|
+
data = json.load(f)
|
|
25
|
+
return data.get(key)
|
|
26
|
+
except (json.JSONDecodeError, OSError):
|
|
27
|
+
return None
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def set_config(key: str, value: str) -> None:
|
|
31
|
+
"""Write a value to ~/.stata-cli/config.json."""
|
|
32
|
+
os.makedirs(_CONFIG_DIR, exist_ok=True)
|
|
33
|
+
data = {}
|
|
34
|
+
if os.path.isfile(_CONFIG_FILE):
|
|
35
|
+
try:
|
|
36
|
+
with open(_CONFIG_FILE, encoding="utf-8") as f:
|
|
37
|
+
data = json.load(f)
|
|
38
|
+
except (json.JSONDecodeError, OSError):
|
|
39
|
+
pass
|
|
40
|
+
data[key] = value
|
|
41
|
+
with open(_CONFIG_FILE, "w", encoding="utf-8") as f:
|
|
42
|
+
json.dump(data, f, indent=2, ensure_ascii=False)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def get_all_config() -> dict:
|
|
46
|
+
"""Read all config values."""
|
|
47
|
+
if not os.path.isfile(_CONFIG_FILE):
|
|
48
|
+
return {}
|
|
49
|
+
try:
|
|
50
|
+
with open(_CONFIG_FILE, encoding="utf-8") as f:
|
|
51
|
+
return json.load(f)
|
|
52
|
+
except (json.JSONDecodeError, OSError):
|
|
53
|
+
return {}
|
|
54
|
+
|
|
13
55
|
|
|
14
56
|
def detect_stata_path() -> str | None:
|
|
15
57
|
"""Auto-detect the Stata installation directory.
|
|
16
58
|
|
|
17
59
|
Checks, in order:
|
|
18
60
|
1. STATA_PATH environment variable
|
|
19
|
-
2.
|
|
61
|
+
2. ~/.stata-cli/config.json (user-configured path)
|
|
62
|
+
3. Platform-specific default locations
|
|
20
63
|
"""
|
|
21
64
|
env_path = os.environ.get("STATA_PATH")
|
|
22
65
|
if env_path and os.path.exists(env_path):
|
|
23
66
|
return env_path
|
|
24
67
|
|
|
68
|
+
config_path = get_config("stata-path")
|
|
69
|
+
if config_path and os.path.exists(config_path):
|
|
70
|
+
return config_path
|
|
71
|
+
|
|
25
72
|
if IS_MACOS:
|
|
26
73
|
for candidate in [
|
|
27
74
|
"/Applications/Stata",
|
|
28
75
|
"/Applications/StataNow",
|
|
29
|
-
"/Applications/Stata18",
|
|
30
|
-
"/Applications/Stata17",
|
|
31
76
|
]:
|
|
32
77
|
if os.path.exists(candidate):
|
|
33
78
|
return candidate
|
|
34
79
|
|
|
35
80
|
elif IS_WINDOWS:
|
|
36
|
-
for version in ["18", "17", "16"]:
|
|
37
|
-
for prefix in [
|
|
81
|
+
for version in ["19", "18", "17", "16"]:
|
|
82
|
+
for prefix in [
|
|
83
|
+
r"C:\Program Files\Stata",
|
|
84
|
+
r"C:\Program Files\StataNow",
|
|
85
|
+
]:
|
|
38
86
|
candidate = prefix + version
|
|
39
87
|
if os.path.exists(candidate):
|
|
40
88
|
return candidate
|
|
41
89
|
|
|
42
90
|
elif IS_LINUX:
|
|
43
|
-
for candidate in [
|
|
91
|
+
for candidate in [
|
|
92
|
+
"/usr/local/stata19",
|
|
93
|
+
"/usr/local/statanow19",
|
|
94
|
+
"/usr/local/stata18",
|
|
95
|
+
"/usr/local/stata17",
|
|
96
|
+
"/usr/local/stata",
|
|
97
|
+
]:
|
|
44
98
|
if os.path.exists(candidate):
|
|
45
99
|
return candidate
|
|
46
100
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: stata-cli
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.2
|
|
4
4
|
Summary: Command-line interface for running Stata commands via PyStata
|
|
5
5
|
License: MIT
|
|
6
6
|
Keywords: stata,cli,statistics,data-science
|
|
@@ -51,7 +51,7 @@ A command-line interface for [Stata](https://www.stata.com/) via PyStata — bui
|
|
|
51
51
|
| **Frame Management** | List Stata frames and current working frame via `frame` |
|
|
52
52
|
| **Help System** | Browse Stata help topics with SMCL-to-plain-text conversion |
|
|
53
53
|
| **Graph Export** | Auto-detect and export graphs as PNG/SVG/PDF to `~/.stata-cli/graphs/` |
|
|
54
|
-
| **Daemon Mode** | Persistent background process for sub-second execution via
|
|
54
|
+
| **Daemon Mode** | Persistent background process for sub-second execution; parallel sessions via `--session` |
|
|
55
55
|
| **Output Control** | Compact mode, JSON output, token limit management, log file output |
|
|
56
56
|
| **Interruption** | Send break signal to stop long-running commands |
|
|
57
57
|
| **Skill Library** | Built-in Stata reference with 57 topics: syntax, econometrics, causal inference, packages |
|
|
@@ -290,13 +290,32 @@ stata-cli daemon stop # Shut down
|
|
|
290
290
|
|---------|-------------|
|
|
291
291
|
| `daemon start` | Start the background daemon process |
|
|
292
292
|
| `daemon stop` | Graceful shutdown |
|
|
293
|
-
| `daemon
|
|
293
|
+
| `daemon stop --all` | Stop all running sessions |
|
|
294
|
+
| `daemon status` | Show all running sessions (PID, uptime, idle) |
|
|
294
295
|
| `daemon restart` | Stop + start (clean Stata state) |
|
|
295
296
|
|
|
296
297
|
Commands auto-route through the daemon when it is running. Use `--no-daemon` to force direct execution.
|
|
297
298
|
|
|
298
299
|
The daemon auto-shuts down after 1 hour of inactivity (configurable with `--idle-timeout`).
|
|
299
300
|
|
|
301
|
+
### Parallel Sessions
|
|
302
|
+
|
|
303
|
+
Run multiple independent Stata instances — like opening multiple Stata windows:
|
|
304
|
+
|
|
305
|
+
```bash
|
|
306
|
+
# Start named sessions
|
|
307
|
+
stata-cli --session proj_a daemon start
|
|
308
|
+
stata-cli --session proj_b daemon start
|
|
309
|
+
|
|
310
|
+
# Each session has its own data, estimates, and macros
|
|
311
|
+
stata-cli --session proj_a run "use project_a.dta, clear"
|
|
312
|
+
stata-cli --session proj_b run "use project_b.dta, clear"
|
|
313
|
+
|
|
314
|
+
# Route any command to a specific session
|
|
315
|
+
stata-cli --session proj_a run "regress price mpg weight"
|
|
316
|
+
stata-cli --session proj_b return e
|
|
317
|
+
```
|
|
318
|
+
|
|
300
319
|
## Advanced Usage
|
|
301
320
|
|
|
302
321
|
### Global Options
|
|
@@ -305,6 +324,7 @@ The daemon auto-shuts down after 1 hour of inactivity (configurable with `--idle
|
|
|
305
324
|
|--------|-------------|---------|
|
|
306
325
|
| `--stata-path PATH` | Stata installation directory | auto-detected |
|
|
307
326
|
| `--edition [mp\|se\|be]` | Stata edition | `mp` |
|
|
327
|
+
| `--session NAME` | Daemon session name (for parallel sessions) | `default` |
|
|
308
328
|
| `--compact` | Strip verbose output noise | off |
|
|
309
329
|
| `--json` | Structured JSON output | off |
|
|
310
330
|
| `--timeout SECONDS` | Execution timeout | 600 |
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.5.0"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/references/basics-getting-started.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/references/descriptive-statistics.md
RENAMED
|
File without changes
|
{stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/references/difference-in-differences.md
RENAMED
|
File without changes
|
{stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/references/external-tools-integration.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/references/limited-dependent-variables.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/references/mata-matrix-operations.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/references/mathematical-functions.md
RENAMED
|
File without changes
|
|
File without changes
|
{stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/references/missing-data-handling.md
RENAMED
|
File without changes
|
{stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/references/nonparametric-methods.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/references/regression-discontinuity.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{stata_cli-0.5.0 → stata_cli-0.5.2}/src/stata_cli/skills/references/workflow-best-practices.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|