1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//! # Command Handlers
//!
//! This module contains the implementation of all CLI subcommands for `flk`.
//! Each submodule corresponds to a CLI command and contains the business logic
//! for that operation.
//!
//! ## Command Categories
//!
//! ### Project Setup
//! - [`init`] - Initialize a new flake environment with language detection
//! - [`activate`] - Enter the Nix development shell
//! - [`profiles`] - Create, remove, list, and set default profiles
//!
//! ### Package Management
//! - [`add`] - Add packages to the environment (with optional version pinning)
//! - [`remove`] - Remove packages from the environment
//! - [`search`] - Search nixpkgs for packages
//! - [`list`] - List installed packages
//!
//! ### Environment Customization
//! - [`command`] - Add/remove custom shell commands
//! - [`env`] - Add/remove environment variables
//!
//! ### State Management
//! - [`update`] - Update flake inputs
//! - [`lock`] - Manage flake.lock backups and restoration
//!
//! ### Integration & Export
//! - [`export`] - Export to Docker, Podman, or JSON
//! - [`direnv`] - Manage direnv integration
//! - [`hook`] - Generate shell hooks for bash/zsh/fish
//! - [`completions`] - Generate shell completions
//!
//! ### Display
//! - [`show`] - Pretty-print flake configuration
/// Process-global mutex used by command tests that mutate `cwd`. Multiple
/// tests cd-ing into tempdirs in parallel would race, so each such test takes
/// this lock for its duration.
///
/// Returns a guard that tolerates poisoning — a panicking test leaves the
/// mutex poisoned, but the only state we share is `cwd`, which each test
/// resets via `set_current_dir`, so it's safe to keep using.
pub