deploylane 0.1.4__py3-none-any.whl → 0.1.5__py3-none-any.whl

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.
deploylane/cli.py CHANGED
@@ -1,7 +1,9 @@
1
1
  from __future__ import annotations
2
2
  from typing import Dict, Optional, Tuple, Any, List
3
3
  import typer
4
+ import sys
4
5
  from typing import Optional
6
+ from typer.main import get_command
5
7
  from pathlib import Path
6
8
  from .auth import (
7
9
  login as do_login,
@@ -27,7 +29,9 @@ from .config import (
27
29
  env_fallback_host,
28
30
  env_fallback_token,
29
31
  normalize_host,
30
- get_profile
32
+ get_profile,
33
+ set_active_profile_name,
34
+ save_config
31
35
  )
32
36
  from .ymlvars import (
33
37
  write_vars_file,
@@ -44,6 +48,33 @@ from .ymlvars import (
44
48
  app = typer.Typer(add_completion=True, no_args_is_help=True)
45
49
 
46
50
 
51
+ SKIP_PROFILE_BANNER = {
52
+ "profile-use",
53
+ "profiles-list",
54
+ "login",
55
+ "logout",
56
+ }
57
+
58
+ @app.callback(invoke_without_command=False)
59
+ def _global_callback(ctx: typer.Context) -> None:
60
+ # Don't print during help/completion parsing
61
+ if getattr(ctx, "resilient_parsing", False):
62
+ return
63
+
64
+ # IMPORTANT: actual command name
65
+ sub = (ctx.invoked_subcommand or "").strip()
66
+
67
+ if sub in SKIP_PROFILE_BANNER:
68
+ return
69
+
70
+ cfg = load_config()
71
+ active = get_active_profile_name(cfg)
72
+ prof = get_profile(cfg, active)
73
+
74
+ typer.secho(f"▶ profile: {active}", fg=typer.colors.GREEN, bold=True)
75
+ if prof is None:
76
+ typer.secho(" (not logged in for this profile)", fg=typer.colors.YELLOW)
77
+
47
78
  def get_active_profile_or_exit() -> Profile:
48
79
  cfg = load_config()
49
80
  active = get_active_profile_name(cfg)
@@ -468,5 +499,44 @@ def vars_diff(
468
499
  if exit_code:
469
500
  raise typer.Exit(code=2)
470
501
 
502
+ @app.command("profiles-list")
503
+ def profiles_list() -> None:
504
+ """List stored profiles and show the active one."""
505
+ cfg = load_config()
506
+ active = get_active_profile_name(cfg)
507
+
508
+ profiles = cfg.get("profiles", {})
509
+ if not isinstance(profiles, dict) or not profiles:
510
+ typer.echo("No profiles found. Run: dlane login")
511
+ raise typer.Exit(code=1)
512
+
513
+ # Deterministic ordering
514
+ for name in sorted(profiles.keys()):
515
+ mark = "*" if name == active else " "
516
+ p = profiles.get(name, {})
517
+ host = p.get("host", "")
518
+ typer.echo(f"{mark} {name}\t{host}")
519
+
520
+ typer.echo("")
521
+ typer.echo(f"Active profile: {active}")
522
+
523
+ @app.command("profile-use")
524
+ def profile_use(
525
+ profile: str = typer.Option(..., "--profile", help="Profile name to activate"),
526
+ ) -> None:
527
+ """Set active profile (does not modify credentials)."""
528
+ cfg = load_config()
529
+
530
+ profiles = cfg.get("profiles", {})
531
+ if not isinstance(profiles, dict) or profile not in profiles:
532
+ _err(f"Profile not found: {profile}. Use: dlane profiles-list")
533
+
534
+ set_active_profile_name(cfg, profile)
535
+ save_config(cfg)
536
+
537
+ typer.secho("OK", fg=typer.colors.GREEN)
538
+ typer.echo(f"Active profile set to: {profile}")
539
+ typer.echo(f"Config: {config_path()}")
540
+
471
541
  if __name__ == "__main__":
472
542
  app()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: deploylane
3
- Version: 0.1.4
3
+ Version: 0.1.5
4
4
  Summary: DeployLane - GitLab-focused deployment helper CLI
5
5
  Requires-Python: >=3.10
6
6
  Description-Content-Type: text/markdown
@@ -1,12 +1,12 @@
1
1
  deploylane/__init__.py,sha256=p1em6j4Md5OnaRvfNJ_TuKflAR1JugHxOfATYMkcv-Q,47
2
2
  deploylane/auth.py,sha256=IeE6xKteNvKwZm0gWZlJWVzl2wxDDl8KB2HbkpLeIkg,2854
3
- deploylane/cli.py,sha256=4_4lmyNHKm9dU_6gz0To0rIF1wq_PiocPR-8cl5tKgo,15704
3
+ deploylane/cli.py,sha256=0w9whaa7lKZQwNGhrbagHYBAbslcUMyR1iRF_vYN3Ho,17790
4
4
  deploylane/config.py,sha256=mG2__gEBeJW0qU4KjFiG8-3PGBRLU3PaDZLjFEE_gyM,4171
5
5
  deploylane/gitlab.py,sha256=dv4Q2O_BKlpzjxzSrWr_mji0rK-JIQTmhCWgvSVPE-Y,8818
6
6
  deploylane/utils.py,sha256=iIWifs3k9jXceDBhJCVSQ82vJmWy9Y8u-6mh4lwKnFc,499
7
7
  deploylane/ymlvars.py,sha256=yigS4O_8dskZFX_oOBmKZM166oVom5SlEzPAzqmYk7Q,2804
8
- deploylane-0.1.4.dist-info/METADATA,sha256=K6iyRSay0dZzq5HtCnrR-MJXOWPpI0uvPrC_5d2Ysnw,5358
9
- deploylane-0.1.4.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
10
- deploylane-0.1.4.dist-info/entry_points.txt,sha256=w9v9vKbrG-nioZD1iSZ_Oh7qhV3jvEAXWmbyUqAYDvw,45
11
- deploylane-0.1.4.dist-info/top_level.txt,sha256=sZt2tR7Vx9UZrjWdmzYfF1-kkY2iOitTZTvqG33ojT8,11
12
- deploylane-0.1.4.dist-info/RECORD,,
8
+ deploylane-0.1.5.dist-info/METADATA,sha256=8n2EKj2uLpOP-vNlARtOcMF7h2P7EZgJTEp2yZj_EuE,5358
9
+ deploylane-0.1.5.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
10
+ deploylane-0.1.5.dist-info/entry_points.txt,sha256=w9v9vKbrG-nioZD1iSZ_Oh7qhV3jvEAXWmbyUqAYDvw,45
11
+ deploylane-0.1.5.dist-info/top_level.txt,sha256=sZt2tR7Vx9UZrjWdmzYfF1-kkY2iOitTZTvqG33ojT8,11
12
+ deploylane-0.1.5.dist-info/RECORD,,