0
# Command Line Interface
1
2
Main entry point and command-line argument processing for the nodeenv tool. Provides comprehensive argument parsing, configuration loading, and orchestration of environment creation operations.
3
4
## Capabilities
5
6
### Main Entry Point
7
8
Primary entry point for the nodeenv command-line tool that handles argument parsing, configuration loading, and orchestrates the entire environment creation process.
9
10
```python { .api }
11
def main():
12
"""
13
Entry point for nodeenv command-line tool.
14
15
Processes command-line arguments, loads configuration, and creates
16
Node.js virtual environments based on provided options.
17
18
Handles special cases like --dump-config-defaults and manages
19
global settings for SSL certificates and mirror URLs.
20
"""
21
```
22
23
Usage examples:
24
25
```python
26
import nodeenv
27
import sys
28
29
# Create environment with specific Node.js version
30
sys.argv = ['nodeenv', '--node=16.20.0', 'myenv']
31
nodeenv.main()
32
33
# Create environment with npm and custom jobs
34
sys.argv = ['nodeenv', '--with-npm', '--jobs=4', 'myenv']
35
nodeenv.main()
36
37
# List available Node.js versions
38
sys.argv = ['nodeenv', '--list']
39
nodeenv.main()
40
```
41
42
### Argument Parser Creation
43
44
Creates and configures the argument parser with all available command-line options for nodeenv.
45
46
```python { .api }
47
def make_parser():
48
"""
49
Create argument parser for nodeenv command-line interface.
50
51
Returns:
52
argparse.ArgumentParser: Configured parser with all nodeenv options
53
54
Includes options for:
55
- Node.js version selection
56
- npm configuration
57
- Environment path and naming
58
- Build options (jobs, SSL, source vs prebuilt)
59
- Mirror and proxy settings
60
- Integration with Python virtualenv
61
"""
62
```
63
64
### Argument Parsing
65
66
Parses command-line arguments and validates them according to nodeenv requirements.
67
68
```python { .api }
69
def parse_args(check=True):
70
"""
71
Parse command-line arguments for nodeenv.
72
73
Parameters:
74
check (bool): Whether to perform validation checks on arguments
75
76
Returns:
77
argparse.Namespace: Parsed arguments object
78
79
Validates argument combinations and sets up proper defaults
80
based on the current environment and configuration.
81
"""
82
```
83
84
### Logger Creation
85
86
Creates and configures logging for nodeenv operations with appropriate verbosity levels.
87
88
```python { .api }
89
def create_logger():
90
"""
91
Create logger instance for nodeenv operations.
92
93
Returns:
94
logging.Logger: Configured logger instance
95
96
Sets up logging with appropriate formatters and handlers
97
for console output during environment creation and management.
98
"""
99
```