or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

cli.mdconfiguration.mdindex.mdlicensing.mdobfuscation.mdplatform-support.mdproject-management.md

cli.mddocs/

0

# Command Line Interface

1

2

PyArmor provides both modern streamlined commands and legacy full-featured commands for comprehensive script obfuscation and management. The CLI is the primary interface for most users, offering intuitive commands for obfuscation, configuration, and license management.

3

4

## Capabilities

5

6

### Modern CLI Commands

7

8

#### Generation Command (gen)

9

10

Main obfuscation command supporting script obfuscation, runtime generation, and key creation with extensive customization options.

11

12

```bash { .api }

13

# Generate obfuscated scripts

14

pyarmor gen [options] <scripts>

15

16

# Generate runtime key only

17

pyarmor gen key [options]

18

19

# Generate runtime package only

20

pyarmor gen runtime [options]

21

22

# Common options:

23

# -O, --output PATH Output directory (default: dist)

24

# -r, --recursive Search scripts recursively

25

# --exclude PATTERN Exclude files/paths matching pattern

26

# --obf-module {0,1} Module obfuscation (default: 1)

27

# --obf-code {0,1,2} Code obfuscation (default: 1)

28

# --no-wrap Disable wrap mode

29

# --mix-str Protect string constants

30

# --enable {jit,bcc,rft,themida} Advanced protection features

31

# --private Private mode for scripts

32

# --restrict Restrict mode for packages

33

# --platform NAME Cross-platform obfuscation

34

# --pack {onefile,onedir} Pack with PyInstaller

35

# --use-runtime PATH Use existing runtime package

36

# --outer Enable outer runtime key

37

# -e, --expired DATE Set expiration date (YYYY-MM-DD)

38

# --period N Check runtime key every N days

39

# -b, --bind-device DEV Bind to hardware device

40

# --bind-data STRING Store user data in runtime key

41

```

42

43

#### Configuration Command (cfg)

44

45

Manage PyArmor configuration settings at global, local, and project levels with hierarchical inheritance and interactive editing.

46

47

```bash { .api }

48

# Show all configuration options

49

pyarmor cfg

50

51

# Show specific option value

52

pyarmor cfg OPTION

53

54

# Set option value

55

pyarmor cfg OPTION=VALUE

56

57

# Configuration options:

58

# -p NAME Private settings for module/package

59

# -g, --global Global settings (default: local)

60

# -r, --reset Reset option to default value

61

# --encoding ENCODING Configuration file encoding

62

```

63

64

#### Registration Command (reg)

65

66

Handle PyArmor license registration, upgrades, and device management for commercial usage and advanced features.

67

68

```bash { .api }

69

# Show current license information

70

pyarmor reg

71

72

# Register new license

73

pyarmor reg [options] <regfile>

74

75

# Registration options:

76

# -p, --product NAME Bind license to product name

77

# -u, --upgrade Upgrade old PyArmor license

78

# -g, --device ID Device ID for group license (1-100)

79

# --buy Open purchase link in browser

80

# -C, --CI Request CI pipeline license

81

# -y, --confirm Skip confirmation prompts

82

```

83

84

#### Manual Command (man)

85

86

Launch interactive PyArmor Man shell for learning, troubleshooting, and getting help with PyArmor features and workflows.

87

88

```bash { .api }

89

# Start interactive help system

90

pyarmor man

91

92

# Features:

93

# - Interactive tutorials and guides

94

# - Problem diagnosis and solutions

95

# - Command examples and templates

96

# - Bug reporting assistance

97

```

98

99

### Extended Commands

100

101

#### Project Initialization (init)

102

103

Initialize a PyArmor project in the current directory with default configuration and project structure.

104

105

```bash { .api }

106

# Initialize project in current directory

107

pyarmor init [options]

108

109

# Options:

110

# --src PATH Source directory (default: src)

111

# --output PATH Output directory (default: dist)

112

# --entry SCRIPT Entry script name

113

```

114

115

#### Environment Management (env)

116

117

Check and configure PyArmor environment settings, platform support, and system dependencies.

118

119

```bash { .api }

120

# Check environment status

121

pyarmor env

122

123

# Set environment variables

124

pyarmor env OPTION=VALUE

125

126

# Environment options:

127

# --check Validate environment setup

128

# --platform Show platform information

129

# --runtime Check runtime library status

130

```

131

132

#### Project Build (build)

133

134

Build entire project by obfuscating all configured scripts with project-specific settings and options.

135

136

```bash { .api }

137

# Build project with current settings

138

pyarmor build [options]

139

140

# Options:

141

# --force Force rebuild all scripts

142

# --clean Clean output directory first

143

# --exclude PATTERN Additional exclusion patterns

144

```

145

146

### Legacy CLI Commands (pyarmor-7)

147

148

#### Direct Obfuscation (obfuscate)

149

150

Obfuscate scripts directly without creating a project, suitable for one-time obfuscation tasks.

151

152

```bash { .api }

153

# Basic obfuscation

154

pyarmor-7 obfuscate [options] <scripts>

155

156

# Advanced obfuscation options:

157

# --src PATH Source directory

158

# --entry SCRIPT Entry script

159

# --output PATH Output directory

160

# --recursive Recursive mode

161

# --exclude PATTERN Exclude patterns

162

# --exact Exact match mode

163

# --no-bootstrap Skip bootstrap code

164

# --no-cross-protection Disable cross protection

165

# --plugin NAME Load plugin

166

# --platform NAME Target platform

167

# --advanced {0,1,2,3,4,5} Advanced mode level

168

# --restrict {0,1,2,3} Restriction mode

169

```

170

171

#### Project Management Commands

172

173

```bash { .api }

174

# Initialize new project

175

pyarmor-7 init [options] <name>

176

177

# Configure project

178

pyarmor-7 config [options] <project>

179

180

# Build project

181

pyarmor-7 build [options] <project>

182

183

# Show project information

184

pyarmor-7 info <project>

185

186

# Check project consistency

187

pyarmor-7 check <project>

188

```

189

190

#### License Generation (licenses)

191

192

Generate license files with hardware binding, expiration dates, and custom restrictions.

193

194

```bash { .api }

195

# Generate license file

196

pyarmor-7 licenses [options] <code>

197

198

# License options:

199

# --output PATH Output directory

200

# --expired DATE Expiration date

201

# --bind-disk SERIAL Bind to disk serial number

202

# --bind-mac ADDR Bind to MAC address

203

# --bind-ipv4 ADDR Bind to IPv4 address

204

# --bind-domain NAME Bind to domain name

205

# --enable-period-mode Enable periodic checking

206

```

207

208

#### Packaging Integration (pack)

209

210

Package obfuscated scripts with PyInstaller, py2exe, cx_Freeze, or py2app for distribution.

211

212

```bash { .api }

213

# Pack with PyInstaller

214

pyarmor-7 pack [options] <script>

215

216

# Packaging options:

217

# --type {auto,pyinstaller,py2exe,cx_Freeze,py2app}

218

# --options "OPTS" Additional packer options

219

# --clean Clean temporary files

220

# --debug Enable debug mode

221

```

222

223

### Utility Commands

224

225

#### Hardware Information (hdinfo)

226

227

Display hardware information for device binding configuration and license generation.

228

229

```bash { .api }

230

# Show all hardware information

231

pyarmor-7 hdinfo

232

233

# Show specific hardware info

234

pyarmor-7 hdinfo --disk

235

pyarmor-7 hdinfo --mac

236

pyarmor-7 hdinfo --ipv4

237

pyarmor-7 hdinfo --domain

238

```

239

240

#### Platform Support (download)

241

242

Download platform-specific runtime libraries for cross-platform obfuscation support.

243

244

```bash { .api }

245

# Download platform libraries

246

pyarmor-7 download <platform>

247

248

# List available platforms

249

pyarmor-7 download --list

250

251

# Update platform index

252

pyarmor-7 download --update

253

```

254

255

#### Performance Testing (benchmark)

256

257

Run performance benchmarks to measure obfuscation overhead and optimization effectiveness.

258

259

```bash { .api }

260

# Run benchmark tests

261

pyarmor-7 benchmark [options]

262

263

# Benchmark options:

264

# --timeout SECONDS Test timeout

265

# --debug Verbose output

266

# --mode {1,2,3,4,5} Protection mode

267

```

268

269

## Usage Examples

270

271

### Basic Script Obfuscation

272

273

```bash

274

# Simple obfuscation

275

pyarmor gen hello.py

276

277

# Recursive obfuscation with string protection

278

pyarmor gen --recursive --mix-str src/

279

280

# Cross-platform obfuscation

281

pyarmor gen --platform linux.x86_64,windows.x86_64 src/

282

```

283

284

### Advanced Protection

285

286

```bash

287

# Maximum protection with hardware binding

288

pyarmor gen --enable bcc --enable rft --bind-device "00:11:22:33:44:55" \

289

--expired "2024-12-31" --private src/

290

291

# Themida protection (Windows only)

292

pyarmor gen --enable themida --restrict src/

293

```

294

295

### Project-Based Workflow

296

297

```bash

298

# Initialize and configure project

299

pyarmor init --src myapp --entry main.py

300

pyarmor cfg obf_code=2

301

pyarmor cfg mix_str=1

302

303

# Build project

304

pyarmor build

305

```

306

307

### License Management

308

309

```bash

310

# Register PyArmor license

311

pyarmor reg -p "MyProduct" pyarmor-regcode-xxxx.txt

312

313

# Generate restricted licenses

314

pyarmor-7 licenses --expired 2024-12-31 --bind-mac "00:11:22:33:44:55" \

315

MYAPP-001

316

```

317

318

### Packaging Integration

319

320

```bash

321

# Pack with PyInstaller

322

pyarmor gen --pack onefile main.py

323

324

# Legacy packing

325

pyarmor-7 pack --type pyinstaller --options "--noconsole" main.py

326

```

327

328

## CLI Architecture Components

329

330

### Command Management

331

332

```python { .api }

333

class Commander:

334

"""

335

Modern CLI command architecture and management system.

336

"""

337

338

def init_parser(self, subparsers) -> None:

339

"""

340

Initialize project command parser.

341

342

Args:

343

subparsers: Argument parser subparsers object

344

"""

345

346

def env_parser(self, subparsers) -> None:

347

"""

348

Initialize environment command parser.

349

350

Args:

351

subparsers: Argument parser subparsers object

352

"""

353

354

def build_parser(self, subparsers) -> None:

355

"""

356

Initialize build command parser.

357

358

Args:

359

subparsers: Argument parser subparsers object

360

"""

361

```