Skip to content

Commit e6f6213

Browse files
authored
Version 0.9.4 (#87)
* make envstack canonical entrypoint, deprecate envshell, adds default prompt string * run commands in non-interactive shell by default * addresses command quote issue * adds --unresolved cli option * update shebang to python3 * adds cache env file * bump version to 0.9.4
1 parent 6874fda commit e6f6213

27 files changed

Lines changed: 299 additions & 218 deletions

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,10 @@ build: clean
3535
# Combined target to build for both platforms
3636
all: build
3737

38-
# Install dryrun target to simulate installation
38+
# Test target to verify the build
3939
test:
40-
$(ENVSTACK_CMD) -- l {ROOT}
40+
$(ENVSTACK_CMD) -- ls -al
41+
${ENVSTACK_CMD} -- which python
4142

4243
# Install dryrun target to simulate installation
4344
dryrun:

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,7 @@ The following environment variables are used to help manage functionality:
592592
| DEFAULT_ENV_STACK | Name of the default environment stack (default) |
593593
| ENVPATH | Colon-separated paths to search for stack files |
594594
| IGNORE_MISSING | Ignore missing stack files when resolving environments |
595+
| INTERACTIVE | Run one-off commands in an interactive shell |
595596
| STACK | Stores the name of the current environment stack |
596597
597598
# Tests

bin/envshell

Lines changed: 0 additions & 42 deletions
This file was deleted.

bin/envshell.bat

Lines changed: 0 additions & 2 deletions
This file was deleted.

bin/hello

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class HelloWrapper(Wrapper):
5050
"""A simple wrapper that prints the value of an environment variable."""
5151
def __init__(self, *args, **kwargs):
5252
super(HelloWrapper, self).__init__(*args, **kwargs)
53+
self.shell = True
5354

5455
def executable(self):
5556
"""Return the executable to run."""

env/cache.env

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env envstack
2+
include: [default]
3+
all: &all
4+
ENVPATH: ${CACHE_ROOT}/env:${DEPLOY_ROOT}/env:${ENVPATH}
5+
PATH: ${CACHE_ROOT}/bin:${DEPLOY_ROOT}/bin:${PATH}
6+
PYTHONPATH: ${CACHE_ROOT}/lib/python:${DEPLOY_ROOT}/lib/python:${PYTHONPATH}
7+
darwin:
8+
<<: *all
9+
CACHE_ROOT: ${HOME}/Library/Caches/pipe/${ENV}
10+
linux:
11+
<<: *all
12+
CACHE_ROOT: ${HOME}/.cache/pipe/${ENV}
13+
windows:
14+
<<: *all
15+
CACHE_ROOT: ${USERPROFILE}/AppData/Local/pipe/cache/${ENV}

env/default.env

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ all: &all
1010
darwin:
1111
<<: *all
1212
ROOT: /Volumes/pipe
13-
PS1: '\[\e[32m\](${ENV})\[\e[0m\] \w\$ '
13+
PS1: '\[\e[32m\](${ENV:=${STACK}})\[\e[0m\] \w\$ '
1414
linux:
1515
<<: *all
1616
ROOT: /mnt/pipe
17-
PS1: '\[\e[32m\](${ENV})\[\e[0m\] \w\$ '
17+
PS1: '\[\e[32m\](${ENV:=${STACK}})\[\e[0m\] \w\$ '
1818
windows:
1919
<<: *all
2020
ROOT: //tools/pipe
21-
PROMPT: $E[32m(${ENV})$E[0m $P$G
21+
PROMPT: $E[32m(${ENV:=${STACK}})$E[0m $P$G

env/distman.env

Lines changed: 0 additions & 11 deletions
This file was deleted.

lib/envstack/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
#
33
# Copyright (c) 2024-2025, Ryan Galloway (ryan@rsgalloway.com)
44
#
@@ -34,6 +34,6 @@
3434
"""
3535

3636
__prog__ = "envstack"
37-
__version__ = "0.9.3"
37+
__version__ = "0.9.4"
3838

3939
from envstack.env import clear, init, revert, save # noqa: F401

lib/envstack/cli.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
#
33
# Copyright (c) 2024-2025, Ryan Galloway (ryan@rsgalloway.com)
44
#
@@ -161,11 +161,6 @@ def parse_args():
161161
action="store_true",
162162
help="create a bare environment",
163163
)
164-
parser.add_argument(
165-
"--shell",
166-
action="store_true",
167-
help="drop into a shell with the environment loaded",
168-
)
169164
encrypt_group = parser.add_argument_group("encryption options")
170165
encrypt_group.add_argument(
171166
"-e",
@@ -226,6 +221,12 @@ def parse_args():
226221
metavar="SCOPE",
227222
help="search scope for environment stack files",
228223
)
224+
parser.add_argument(
225+
"-u",
226+
"--unresolved",
227+
action="store_true",
228+
help="dump unresolved environment variables to stdout",
229+
)
229230
parser.add_argument(
230231
"-r",
231232
"--resolve",
@@ -263,11 +264,11 @@ def envshell(namespace: List[str] = None):
263264
"""Run a shell in the given environment stack."""
264265
from .envshell import EnvshellWrapper
265266

266-
print("\U0001F680 Launching envshell... CTRL+D to exit")
267+
print("\U0001F680 Launching envstack shell... CTRL+D to exit")
267268

268269
name = (namespace or [config.DEFAULT_NAMESPACE])[:]
269-
envshell = EnvshellWrapper(name)
270-
return envshell.launch()
270+
shell = EnvshellWrapper(name)
271+
return shell.launch()
271272

272273

273274
def whichenv():
@@ -292,9 +293,6 @@ def main():
292293
if command:
293294
return run_command(command, args.namespace)
294295

295-
elif args.shell:
296-
return envshell(args.namespace)
297-
298296
elif args.keygen:
299297
from envstack.encrypt import generate_keys
300298

@@ -445,13 +443,16 @@ def main():
445443
for source in env.sources:
446444
print(source.path)
447445

448-
else:
446+
elif args.unresolved:
449447
env = load_environ(
450448
args.namespace, platform=args.platform, encrypt=args.encrypt
451449
)
452450
for k, v in sorted(env.items(), key=lambda x: str(x[0])):
453451
print(f"{k}={v}")
454452

453+
else:
454+
return envshell(args.namespace)
455+
455456
except KeyboardInterrupt:
456457
print("Stopping...")
457458
return 2

0 commit comments

Comments
 (0)