scoop-uv 0.9.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
//! 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,

        /// 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,
    },
}

/// 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,
}