scoop-uv 0.12.0

Scoop up your Python envs — pyenv-style workflow powered by uv
Documentation
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
//! CLI module

pub mod commands;

use std::path::PathBuf;

use clap::{ArgAction, Parser, Subcommand};

/// scoop - Python virtual environment manager powered by uv
#[derive(Parser, Debug)]
#[command(name = "scoop")]
#[command(author, version, about, long_about = None)]
#[command(propagate_version = true)]
pub struct Cli {
    /// Subcommand to run
    #[command(subcommand)]
    pub command: Commands,

    /// Suppress all output
    #[arg(short, long, global = true)]
    pub quiet: bool,

    /// Disable colored output
    #[arg(long, global = true, env = "NO_COLOR")]
    pub no_color: bool,
}

/// Source type for migration
#[derive(Debug, Clone, Copy, PartialEq, Eq, clap::ValueEnum)]
pub enum MigrateSource {
    /// pyenv-virtualenv
    Pyenv,
    /// virtualenvwrapper
    Virtualenvwrapper,
    /// conda
    Conda,
}

impl std::fmt::Display for MigrateSource {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            Self::Pyenv => write!(f, "pyenv"),
            Self::Virtualenvwrapper => write!(f, "virtualenvwrapper"),
            Self::Conda => write!(f, "conda"),
        }
    }
}

/// Migrate subcommands
#[derive(Subcommand, Debug)]
pub enum MigrateCommand {
    /// List environments available for migration
    List {
        /// Output as JSON
        #[arg(long)]
        json: bool,

        /// Filter by source tool (pyenv, virtualenvwrapper, conda)
        #[arg(long, value_enum)]
        source: Option<MigrateSource>,
    },
    /// Migrate all environments at once
    All {
        /// Preview migration without making changes
        #[arg(short = 'n', long)]
        dry_run: bool,

        /// Include EOL Python versions and overwrite conflicts
        #[arg(short, long)]
        force: bool,

        /// Skip confirmation prompts
        #[arg(short, long)]
        yes: bool,

        /// Output as JSON
        #[arg(long)]
        json: bool,

        /// Fail migration if any package fails to install
        #[arg(long)]
        strict: bool,

        /// Delete original environments after successful migration
        #[arg(long)]
        delete_source: bool,

        /// Filter by source tool (pyenv, virtualenvwrapper, conda)
        #[arg(long, value_enum)]
        source: Option<MigrateSource>,
    },
    /// Migrate a specific environment
    #[command(name = "@env")]
    Env {
        /// Name of the environment to migrate
        name: String,

        /// Preview migration without making changes
        #[arg(short = 'n', long)]
        dry_run: bool,

        /// Overwrite if environment already exists in scoop
        #[arg(short, long)]
        force: bool,

        /// Skip confirmation prompts
        #[arg(short, long)]
        yes: bool,

        /// Output as JSON
        #[arg(long)]
        json: bool,

        /// Fail migration if any package fails to install
        #[arg(long)]
        strict: bool,

        /// Migrate with a different name
        #[arg(long, value_name = "NEW_NAME")]
        rename: Option<String>,

        /// Auto-rename on conflict (uses {name}-<source> pattern)
        #[arg(long, conflicts_with = "force")]
        auto_rename: bool,

        /// Delete original environment after successful migration
        #[arg(long)]
        delete_source: bool,

        /// Source tool (pyenv, virtualenvwrapper, conda)
        #[arg(long, value_enum)]
        source: Option<MigrateSource>,
    },
}

/// Self-management subcommands (under `scoop self ...`).
#[derive(Subcommand, Debug)]
pub enum SelfCommand {
    /// Reinstall scoop from crates.io to the latest version
    // Disable clap's auto `--version` flag here so `--version <VER>` can be
    // a real arg meaning "install this specific version". `scoop --version`
    // and the auto flag on other subcommands are unaffected.
    #[command(disable_version_flag = true)]
    Update {
        /// Reinstall even if already on the latest version
        #[arg(long)]
        force: bool,

        /// Install a specific version instead of the latest
        #[arg(long, value_name = "VERSION")]
        version: Option<String>,

        /// Skip the post-install environment verification (`scoop doctor`)
        #[arg(long)]
        no_verify: bool,

        /// Output as JSON
        #[arg(long)]
        json: bool,
    },
}

/// Available commands
#[derive(Subcommand, Debug)]
pub enum Commands {
    /// List all virtual environments
    #[command(alias = "ls")]
    List {
        /// Show installed Python versions instead of virtualenvs
        #[arg(long)]
        pythons: bool,

        /// Output names only, one per line (for scripting/completion)
        #[arg(long, hide = true)]
        bare: bool,

        /// Filter environments by Python version (e.g., 3.12)
        #[arg(long, value_name = "VERSION", conflicts_with = "pythons")]
        python_version: Option<String>,

        /// Output as JSON
        #[arg(long)]
        json: bool,
    },

    /// Set local environment for current directory
    Use {
        /// Name of the virtual environment (or "system" for system Python)
        name: Option<String>,

        /// Remove version file (unset local/global setting)
        #[arg(long)]
        unset: bool,

        /// Create .venv symlink to the virtual environment
        #[arg(long, conflicts_with = "no_link")]
        link: bool,

        /// Set as global default
        #[arg(short, long)]
        global: bool,

        /// Do not create .venv symlink (default behavior, explicit)
        #[arg(long, conflicts_with = "link")]
        no_link: bool,

        /// Output as JSON
        #[arg(long)]
        json: bool,
    },

    /// Create a new virtual environment
    Create {
        /// Name of the virtual environment
        name: String,

        /// Python version or specifier (e.g., 3.12, cpython@3.12, pypy@3.10)
        #[arg(default_value = "3")]
        python: String,

        /// Path to a specific Python interpreter to use instead of a version
        #[arg(long = "python-path", value_name = "PATH")]
        python_path: Option<PathBuf>,

        /// Overwrite existing environment
        #[arg(short, long)]
        force: bool,

        /// Install the requested Python version first if it is not already available
        #[arg(long, conflicts_with = "python_path")]
        install_python: bool,

        /// Output as JSON
        #[arg(long)]
        json: bool,
    },

    /// Remove a virtual environment
    #[command(alias = "rm", alias = "delete")]
    Remove {
        /// Name of the virtual environment
        name: String,

        /// Skip confirmation
        #[arg(short, long)]
        force: bool,

        /// Output as JSON
        #[arg(long)]
        json: bool,
    },

    /// Install a Python version
    Install {
        /// Python version to install (e.g., 3.12, 3.13)
        #[arg(name = "VERSION")]
        python_version: Option<String>,

        /// Install latest stable Python (default if no version specified)
        #[arg(long)]
        latest: bool,

        /// Install oldest fully-supported Python (more stable)
        #[arg(long)]
        stable: bool,

        /// Output as JSON
        #[arg(long)]
        json: bool,
    },

    /// Uninstall a Python version
    Uninstall {
        /// Python version to uninstall
        #[arg(name = "VERSION")]
        python_version: String,

        /// Also remove all virtual environments using this Python version
        #[arg(long)]
        cascade: bool,

        /// Skip confirmation for cascade removal
        #[arg(short, long, requires = "cascade")]
        force: bool,

        /// Output as JSON
        #[arg(long)]
        json: bool,
    },

    /// Diagnose installation issues
    Doctor {
        /// Increase verbosity (can be repeated)
        #[arg(short, long, action = ArgAction::Count)]
        verbose: u8,

        /// Output as JSON
        #[arg(long)]
        json: bool,

        /// Automatically fix issues where possible
        #[arg(long)]
        fix: bool,
    },

    /// Show detailed information about a virtual environment
    Info {
        /// Name of the virtual environment
        name: String,

        /// Output as JSON
        #[arg(long)]
        json: bool,

        /// Show all installed packages (default: top 5 only)
        #[arg(long)]
        all_packages: bool,

        /// Skip directory size calculation (faster)
        #[arg(long)]
        no_size: bool,
    },

    /// Output shell initialization script
    Init {
        /// Shell to generate script for
        #[arg(value_enum)]
        shell: ShellType,
    },

    /// Output shell completion script
    Completions {
        /// Shell to generate completions for
        #[arg(value_enum)]
        shell: ShellType,
    },

    /// Resolve and print current environment name
    #[command(hide = true)]
    Resolve,

    /// Output activation script for eval
    #[command(hide = true)]
    Activate {
        /// Name of the virtual environment
        name: String,

        /// Target shell type (auto-detected if not specified)
        #[arg(long, value_enum)]
        shell: Option<ShellType>,
    },

    /// Output deactivation script for eval
    #[command(hide = true)]
    Deactivate {
        /// Target shell type (auto-detected if not specified)
        #[arg(long, value_enum)]
        shell: Option<ShellType>,
    },

    /// Set environment for current shell session only (highest priority)
    Shell {
        /// Name of the virtual environment (or "system" for system Python)
        name: Option<String>,

        /// Clear shell-specific environment setting
        #[arg(long)]
        unset: bool,

        /// Target shell type (auto-detected if not specified)
        #[arg(long, value_enum)]
        shell: Option<ShellType>,
    },

    /// Migrate environments from other tools (pyenv, virtualenvwrapper)
    Migrate {
        /// Subcommand or environment name to migrate
        #[command(subcommand)]
        command: Option<MigrateCommand>,
    },

    /// Set or show language preference
    Lang {
        /// Language code to set (e.g., ko, en)
        lang: Option<String>,

        /// List supported languages
        #[arg(long)]
        list: bool,

        /// Reset to system default
        #[arg(long)]
        reset: bool,

        /// Output as JSON
        #[arg(long)]
        json: bool,
    },

    /// Manage scoop itself (update, etc.)
    #[command(name = "self")]
    Self_ {
        #[command(subcommand)]
        command: SelfCommand,
    },

    /// Show the current environment status
    Status {
        /// Output as JSON
        #[arg(long)]
        json: bool,
    },

    /// Clone an environment (optionally without copying packages)
    Clone {
        /// Name of the source environment
        src: String,

        /// Name of the new (destination) environment
        dst: String,

        /// Skip copying packages — create an empty env with the same Python
        #[arg(long)]
        no_packages: bool,

        /// Overwrite destination if it already exists
        #[arg(short, long)]
        force: bool,

        /// Output as JSON
        #[arg(long)]
        json: bool,
    },

    /// Export an environment as a portable JSON file
    Export {
        /// Name of the environment to export
        name: String,

        /// Write to this path instead of stdout
        #[arg(short = 'o', long = "output", value_name = "PATH")]
        output: Option<PathBuf>,
    },

    /// Import an environment from a `scoop export` JSON file (use `-` for stdin)
    Import {
        /// Path to the export JSON, or `-` to read from stdin
        path: String,

        /// Override the environment name from the file
        #[arg(long, value_name = "NAME")]
        name: Option<String>,

        /// Overwrite an existing environment with the same name
        #[arg(short, long)]
        force: bool,

        /// Output as JSON
        #[arg(long)]
        json: bool,
    },

    /// Sync an environment from `.scoop.toml`
    Sync {
        /// Additional package group(s) to install on top of `default`
        #[arg(long = "with", value_name = "GROUP", action = clap::ArgAction::Append)]
        with: Vec<String>,

        /// Preview the plan without creating env or installing packages
        #[arg(long)]
        dry_run: bool,

        /// Output as JSON
        #[arg(long)]
        json: bool,
    },

    /// Run a command inside an environment without activating it
    Run {
        /// Name of the virtual environment
        env: String,

        /// Command and arguments to execute (use -- to separate, e.g. `scoop run myenv -- python x.py`)
        #[arg(trailing_var_arg = true, allow_hyphen_values = true, num_args = 1..)]
        command: Vec<String>,
    },

    /// Print the full path to an executable in an environment
    Which {
        /// Name of the executable to locate (e.g., python, pip)
        exe: String,

        /// Look in this environment instead of the active one
        #[arg(long, value_name = "NAME")]
        env: Option<String>,

        /// Output as JSON
        #[arg(long)]
        json: bool,
    },

    /// Prune the uv cache (delete unused download/wheel cache entries)
    Prune {
        /// Output as JSON
        #[arg(long)]
        json: bool,
    },

    /// Garbage-collect orphan virtual environments
    Gc {
        /// Actually remove the orphans (default: preview only)
        #[arg(short, long)]
        yes: bool,

        /// Also remove uv-managed Python versions that no environment uses
        #[arg(long)]
        aggressive: bool,

        /// Output as JSON
        #[arg(long)]
        json: bool,
    },

    /// Generate man pages (top-level + one per subcommand)
    Man {
        /// Write `scoop.1` + `scoop-<sub>.1` files into this directory.
        /// Omit to print the top-level page to stdout.
        #[arg(value_name = "DIR")]
        output_dir: Option<PathBuf>,

        /// Output as JSON. Requires `DIR` — JSON has nothing meaningful
        /// to say about a single groff page on stdout, and accepting it
        /// silently would lie to scripts that pipe through `jq`.
        #[arg(long, requires = "output_dir")]
        json: bool,
    },

    /// Verify env health (metadata, python binary, pyvenv.cfg, activate, exec, manifest drift)
    Verify {
        /// Check only this environment (default: every environment)
        #[arg(value_name = "NAME")]
        name: Option<String>,

        /// Exit with status 1 if any check fails (default: always exit 0)
        #[arg(long)]
        strict: bool,

        /// Output as JSON
        #[arg(long)]
        json: bool,
    },
}

/// Supported shell types
#[derive(Debug, Clone, Copy, PartialEq, Eq, clap::ValueEnum)]
pub enum ShellType {
    /// Bash shell
    Bash,
    /// Zsh shell
    Zsh,
    /// Fish shell
    Fish,
    /// PowerShell
    #[value(alias = "pwsh")]
    Powershell,
}