ccgo 3.4.2

A high-performance C++ cross-platform build CLI
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
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
# CLI Command Reference

Complete command-line reference for all CCGO commands.

## Overview

CCGO provides a comprehensive CLI for C++ cross-platform development with fast startup times and zero Python dependencies (Rust implementation).

## Global Options

Available for all commands:

```bash
ccgo [GLOBAL_OPTIONS] <COMMAND> [COMMAND_OPTIONS]
```

| Option | Description |
|--------|-------------|
| `-h, --help` | Print help information |
| `-V, --version` | Print version information |
| `-v, --verbose` | Enable verbose output |
| `--no-color` | Disable colored terminal output |

## Commands Overview

| Category | Command | Description |
|----------|---------|-------------|
| **Project** | [new]#new | Create a new project |
| | [init]#init | Initialize CCGO in existing project |
| **Build** | [build]#build | Build for target platform |
| | [run]#run | Build and run example/binary |
| | [test]#test | Run GoogleTest unit tests |
| | [bench]#bench | Run Google Benchmark benchmarks |
| | [doc]#doc | Generate Doxygen documentation |
| **Dependencies** | [install]#install | Install dependencies from CCGO.toml |
| | [add]#add | Add a dependency |
| | [remove]#remove | Remove a dependency |
| | [update]#update | Update dependencies to latest versions |
| | [vendor]#vendor | Vendor dependencies for offline builds |
| | [tree]#tree | Display dependency tree |
| **Discovery** | [search]#search | Search for packages |
| | [collection]#collection | Manage package collections |
| **Publishing** | [publish]#publish | Publish to package managers |
| | [package]#package | Package SDK for distribution |
| **Maintenance** | [check]#check | Check platform requirements |
| | [clean]#clean | Clean build artifacts |
| | [tag]#tag | Create version tag |

---

## new

Create a new CCGO project from template.

```bash
ccgo new [OPTIONS] <NAME>
```

### Arguments

- `<NAME>` - Project name (required)

### Options

| Option | Description |
|--------|-------------|
| `--template <URL>` | Custom Copier template URL |
| `--defaults` | Use default values without prompting |
| `--vcs-ref <REF>` | Template git reference (branch/tag) |

### Examples

```bash
# Create new project with interactive prompts
ccgo new myproject

# Create with defaults
ccgo new myproject --defaults

# Use custom template
ccgo new myproject --template https://github.com/user/template

# Use specific template version
ccgo new myproject --vcs-ref v2.0.0
```

---

## init

Initialize CCGO in an existing project.

```bash
ccgo init [OPTIONS]
```

### Options

| Option | Description |
|--------|-------------|
| `--template <URL>` | Custom Copier template URL |
| `--defaults` | Use default values without prompting |
| `--force` | Overwrite existing files |

### Examples

```bash
# Initialize in current directory
ccgo init

# Force overwrite existing files
ccgo init --force
```

---

## build

Build C++ library for specific platform(s).

```bash
ccgo build [OPTIONS] <TARGET>
```

### Arguments

- `<TARGET>` - Build target (required)

**Available Targets:**

| Target | Description |
|--------|-------------|
| `all` | All supported platforms |
| `apple` | All Apple platforms (iOS, macOS, watchOS, tvOS) |
| `android` | Android (NDK-based) |
| `ios` | iOS (arm64, simulator) |
| `macos` | macOS (x86_64, arm64 universal) |
| `windows` | Windows (MSVC/MinGW) |
| `linux` | Linux (GCC/Clang) |
| `ohos` | OpenHarmony (Hvigor-based) |
| `watchos` | Apple Watch |
| `tvos` | Apple TV |
| `kmp` | Kotlin Multiplatform |
| `conan` | Conan package |

### Options

| Option | Description |
|--------|-------------|
| `--arch <ARCH>` | Target architectures (comma-separated) |
| `--link-type <TYPE>` | `static`, `shared`, or `both` (default: `both`) |
| `--docker` | Build using Docker container |
| `--auto-docker` | Auto-detect and use Docker when native build not possible |
| `-j, --jobs <N>` | Number of parallel build jobs |
| `--ide-project` | Generate IDE project files (Xcode, Visual Studio, etc.) |
| `--release` | Build in release mode (default: debug) |
| `--native-only` | Build native libraries only, skip AAR/HAR packaging |
| `--toolchain <TOOL>` | Windows toolchain: `msvc`, `mingw`, `auto` (default: `auto`) |
| `--dev` | Development mode (use pre-built ccgo from GitHub in Docker) |
| `-F, --features <FEATURES>` | Enable features (comma-separated) |
| `--no-default-features` | Disable default features |
| `--all-features` | Enable all available features |

### Platform-Specific Architectures

**Android:**
- `armeabi-v7a` - ARM 32-bit
- `arm64-v8a` - ARM 64-bit (default)
- `x86` - Intel 32-bit (emulator)
- `x86_64` - Intel 64-bit (emulator)

**iOS:**
- `arm64` - iPhone/iPad (default)
- `simulator` - Simulator (auto-detects host arch)

**macOS:**
- `x86_64` - Intel Macs
- `arm64` - Apple Silicon
- Universal binary created by default (both architectures)

**Windows:**
- `x86_64` - 64-bit (default)

**Linux:**
- `x86_64` - 64-bit (default)
- `aarch64` - ARM 64-bit

**OpenHarmony:**
- `armeabi-v7a` - ARM 32-bit
- `arm64-v8a` - ARM 64-bit (default)
- `x86_64` - Intel 64-bit

### Features System

Control conditional compilation with features:

```bash
# Enable specific features
ccgo build android --features networking,ssl

# Disable default features and enable only specific ones
ccgo build android --features minimal --no-default-features

# Enable all features
ccgo build android --all-features
```

Features are defined in `CCGO.toml`:

```toml
[features]
default = ["networking"]
networking = []
ssl = ["networking"]
advanced = ["networking", "ssl"]
```

### Docker Builds

Build any platform from any OS using Docker:

```bash
# Explicit Docker usage
ccgo build linux --docker
ccgo build windows --docker
ccgo build android --docker

# Auto-detect when needed (e.g., building Linux from macOS)
ccgo build linux --auto-docker
```

**Benefits:**
- Universal cross-compilation
- No local toolchain installation required
- Consistent build environment
- Pre-built images from Docker Hub

### Examples

```bash
# Build Android with specific architectures
ccgo build android --arch arm64-v8a,armeabi-v7a

# Build iOS in release mode
ccgo build ios --release

# Build for all Apple platforms
ccgo build apple --release

# Build Windows with MSVC toolchain only
ccgo build windows --toolchain msvc

# Build Linux using Docker (from macOS/Windows)
ccgo build linux --docker

# Build with parallel jobs
ccgo build android -j 8

# Build and generate Xcode project
ccgo build ios --ide-project

# Build with specific features
ccgo build android --features networking,ssl --release

# Build all platforms
ccgo build all --release
```

### Build Output

Builds are output to `target/<platform>/` with unified archive structure:

```
target/android/
└── mylib_Android_SDK-1.0.0.zip
    ├── lib/
    │   ├── static/arm64-v8a/libmylib.a
    │   └── shared/arm64-v8a/libmylib.so
    ├── haars/mylib.aar
    ├── include/mylib/
    └── build_info.json
```

---

## test

Run project tests.

```bash
ccgo test [OPTIONS] [PLATFORM]
```

### Arguments

- `[PLATFORM]` - Platform to test on (default: current)

### Options

| Option | Description |
|--------|-------------|
| `--filter <PATTERN>` | Run tests matching pattern |
| `--verbose` | Verbose test output |
| `--no-fail-fast` | Continue running tests after failure |

### Examples

```bash
# Run all tests
ccgo test

# Run specific test
ccgo test --filter test_name

# Run tests verbosely
ccgo test --verbose
```

---

## bench

Run project benchmarks.

```bash
ccgo bench [OPTIONS] [PLATFORM]
```

### Arguments

- `[PLATFORM]` - Platform to benchmark on (default: current)

### Options

| Option | Description |
|--------|-------------|
| `--filter <PATTERN>` | Run benchmarks matching pattern |
| `--baseline <NAME>` | Save/compare against baseline |

### Examples

```bash
# Run all benchmarks
ccgo bench

# Run specific benchmark
ccgo bench --filter bench_name

# Save baseline
ccgo bench --baseline main

# Compare against baseline
ccgo bench --baseline main
```

---

## doc

Generate project documentation.

```bash
ccgo doc [OPTIONS]
```

### Options

| Option | Description |
|--------|-------------|
| `--open` | Open documentation in browser |
| `--no-deps` | Don't include dependencies |
| `--format <FMT>` | Output format: html, markdown |

### Examples

```bash
# Generate and open documentation
ccgo doc --open

# Generate markdown docs
ccgo doc --format markdown
```

---

## install

Install project dependencies.

```bash
ccgo install [OPTIONS]
```

### Options

| Option | Description |
|--------|-------------|
| `--locked` | Use exact versions from CCGO.lock |
| `--offline` | Use vendored dependencies only |

### Examples

```bash
# Install dependencies
ccgo install

# Install with locked versions
ccgo install --locked

# Offline install
ccgo install --offline
```

---

## update

Update dependencies to latest compatible versions.

```bash
ccgo update [OPTIONS] [DEPENDENCY]
```

### Arguments

- `[DEPENDENCY]` - Specific dependency to update (optional)

### Options

| Option | Description |
|--------|-------------|
| `--dry-run` | Show what would be updated |

### Examples

```bash
# Update all dependencies
ccgo update

# Update specific dependency
ccgo update spdlog

# Dry run
ccgo update --dry-run
```

---

## vendor

Copy all dependencies to vendor/ directory for offline builds.

```bash
ccgo vendor [OPTIONS]
```

### Options

| Option | Description |
|--------|-------------|
| `--no-delete` | Don't delete existing vendor directory |

### Examples

```bash
# Vendor all dependencies
ccgo vendor

# Preserve existing vendor directory
ccgo vendor --no-delete
```

---

## tree

Display project dependency tree with various visualization options.

```bash
ccgo tree [OPTIONS] [PACKAGE]
```

### Arguments

- `[PACKAGE]` - Show dependencies of a specific package (optional)

### Options

| Option | Description |
|--------|-------------|
| `-d, --depth <DEPTH>` | Maximum depth to display (default: unlimited) |
| `--no-dedupe` | Don't deduplicate repeated dependencies |
| `-l, --locked` | Show dependency versions from lock file |
| `-f, --format <FORMAT>` | Output format: text, json, dot (default: text) |
| `--duplicates` | Show only duplicate dependencies |
| `-i, --invert <PACKAGE>` | Show packages that depend on this package |
| `--conflicts` | Highlight version conflicts |

### Output Formats

**Text** (default):
- Tree-style visualization with box-drawing characters
- Shows dependency hierarchy
- Marks duplicates with `(*)`

**JSON**:
- Structured data with version and source information
- Includes conflict detection results
- Suitable for programmatic processing

**DOT** (Graphviz):
- Graph visualization format
- Highlights conflicts in red
- Can be rendered with `dot` command

### Examples

```bash
# Show full dependency tree
ccgo tree

# Limit depth to 2 levels
ccgo tree --depth 2

# Show specific package dependencies
ccgo tree spdlog

# Show all occurrences (no deduplication)
ccgo tree --no-dedupe

# Output as JSON
ccgo tree --format json

# Generate Graphviz diagram
ccgo tree --format dot > deps.dot
dot -Tpng deps.dot -o deps.png

# Show reverse dependencies
ccgo tree --invert fmt

# Highlight version conflicts
ccgo tree --conflicts

# Show only duplicate dependencies
ccgo tree --duplicates

# Use locked versions from CCGO.toml.lock
ccgo tree --locked
```

---

## search

Search for packages in subscribed collections.

```bash
ccgo search <QUERY> [OPTIONS]
```

### Arguments

- `<QUERY>` - Search keyword or pattern (required)

### Options

| Option | Description |
|--------|-------------|
| `-c, --collection <NAME>` | Search only in specific collection |
| `-d, --details` | Show detailed package information |
| `--limit <N>` | Limit number of results (default: 20) |

### Examples

```bash
# Search all collections for packages
ccgo search json

# Search in specific collection
ccgo search logging --collection official

# Show detailed information
ccgo search crypto --details

# Limit results to 50
ccgo search lib --limit 50

# Combined options
ccgo search network --collection community --details --limit 10
```

### Search Results

Results include:
- Package name and version
- Summary description
- Source collection
- Repository URL (with --details)
- Supported platforms (with --details)
- License information (with --details)
- Keywords (with --details)

---

## collection

Manage package collections for discovery.

```bash
ccgo collection <SUBCOMMAND> [OPTIONS]
```

### Subcommands

| Subcommand | Description |
|------------|-------------|
| `add <URL>` | Add a new collection |
| `list` | List all subscribed collections |
| `remove <NAME>` | Remove a collection |
| `refresh [NAME]` | Refresh collection(s) |

### collection add

Add a new package collection.

```bash
ccgo collection add <URL>
```

**Supported URL schemes:**
- `file://` - Local file path
- `http://` - HTTP URL
- `https://` - HTTPS URL

**Arguments:**
- `<URL>` - Collection URL (required)

**Examples:**
```bash
# Add official collection
ccgo collection add https://ccgo.dev/collections/official.json

# Add community collection
ccgo collection add https://ccgo.dev/collections/community.json

# Add local collection
ccgo collection add file:///path/to/my-collection.json

# Add from HTTP
ccgo collection add http://example.com/packages.json
```

### collection list

List all subscribed collections.

```bash
ccgo collection list [OPTIONS]
```

**Options:**

| Option | Description |
|--------|-------------|
| `-d, --details` | Show detailed information |

**Examples:**
```bash
# List collections
ccgo collection list

# Show detailed information
ccgo collection list --details
```

### collection remove

Remove a subscribed collection.

```bash
ccgo collection remove <NAME_OR_URL>
```

**Arguments:**
- `<NAME_OR_URL>` - Collection name or URL (required)

**Examples:**
```bash
# Remove by name
ccgo collection remove official

# Remove by URL
ccgo collection remove https://ccgo.dev/collections/community.json
```

### collection refresh

Refresh collection data.

```bash
ccgo collection refresh [NAME]
```

**Arguments:**
- `[NAME]` - Collection name to refresh (optional, default: all)

**Examples:**
```bash
# Refresh all collections
ccgo collection refresh

# Refresh specific collection
ccgo collection refresh official
```

---

## add

Add a dependency to CCGO.toml.

```bash
ccgo add [OPTIONS] <DEPENDENCY>
```

### Arguments

- `<DEPENDENCY>` - Dependency specification

### Dependency Formats

```bash
# Git repository
ccgo add spdlog --git https://github.com/gabime/spdlog.git --tag v1.12.0

# Local path
ccgo add mylib --path ../mylib

# Registry (future)
ccgo add fmt@10.1.1
```

### Options

| Option | Description |
|--------|-------------|
| `--git <URL>` | Git repository URL |
| `--tag <TAG>` | Git tag |
| `--branch <BRANCH>` | Git branch |
| `--rev <REV>` | Git revision |
| `--path <PATH>` | Local path |

### Examples

```bash
# Add from Git with tag
ccgo add spdlog --git https://github.com/gabime/spdlog.git --tag v1.12.0

# Add from local path
ccgo add mylib --path ../mylib
```

---

## remove

Remove a dependency from CCGO.toml.

```bash
ccgo remove <DEPENDENCY>
```

### Arguments

- `<DEPENDENCY>` - Dependency name

### Examples

```bash
# Remove dependency
ccgo remove spdlog
```

---

## publish

Publish library to registry.

```bash
ccgo publish [OPTIONS] <PLATFORM>
```

### Arguments

- `<PLATFORM>` - Platform to publish: android, ios, macos, apple, ohos, conan, kmp

### Options

| Option | Description |
|--------|-------------|
| `--registry <TYPE>` | Registry: local, official, private |
| `--url <URL>` | Custom registry URL (private only) |
| `--skip-build` | Use existing build artifacts |
| `--manager <MGR>` | Package manager (apple): cocoapods, spm, all |
| `--push` | Push git tags (SPM only) |
| `--remote-name <NAME>` | Git remote name (default: origin) |

### Examples

```bash
# Publish Android to Maven Local
ccgo publish android --registry local

# Publish to Maven Central
ccgo publish android --registry official

# Publish iOS to CocoaPods
ccgo publish apple --manager cocoapods

# Publish to SPM with git push
ccgo publish apple --manager spm --push

# Publish to private Maven
ccgo publish android --registry private --url https://maven.example.com
```

---

## check

Check if platform requirements are met.

```bash
ccgo check [OPTIONS] [PLATFORM]
```

### Arguments

- `[PLATFORM]` - Platform to check (default: all)

### Options

| Option | Description |
|--------|-------------|
| `--verbose` | Show detailed check results |

### Examples

```bash
# Check all platforms
ccgo check

# Check specific platform
ccgo check android --verbose
```

---

## clean

Clean build artifacts.

```bash
ccgo clean [OPTIONS]
```

### Options

| Option | Description |
|--------|-------------|
| `--dry-run` | Show what would be deleted |
| `-y, --yes` | Skip confirmation prompt |

### Examples

```bash
# Preview what will be deleted
ccgo clean --dry-run

# Clean without confirmation
ccgo clean -y
```

---

## tag

Create a version tag from CCGO.toml.

```bash
ccgo tag [OPTIONS] [VERSION]
```

### Arguments

- `[VERSION]` - Version tag (default: from CCGO.toml)

### Options

| Option | Description |
|--------|-------------|
| `-m, --message <MSG>` | Tag message |
| `--push` | Push tag to remote |

### Examples

```bash
# Create tag from CCGO.toml version
ccgo tag

# Create custom version tag
ccgo tag v2.0.0 -m "Release 2.0.0"

# Create and push tag
ccgo tag --push
```

---

## package

Package source for distribution.

```bash
ccgo package [OPTIONS]
```

### Options

| Option | Description |
|--------|-------------|
| `--format <FMT>` | Package format: tar.gz, zip (default: tar.gz) |
| `--output <PATH>` | Output path |

### Examples

```bash
# Create source package
ccgo package

# Create ZIP package
ccgo package --format zip

# Custom output path
ccgo package --output /path/to/output
```

---

## run

Build and run example or binary.

```bash
ccgo run [OPTIONS] <TARGET>
```

### Arguments

- `<TARGET>` - Example or binary name

### Options

| Option | Description |
|--------|-------------|
| `--example` | Run as example (default if TARGET in examples/) |
| `--bin` | Run as binary |
| `--release` | Build in release mode |
| `-- <ARGS>` | Arguments to pass to the program |

### Examples

```bash
# Run example
ccgo run my_example

# Run with arguments
ccgo run my_example -- --arg1 value1

# Run in release mode
ccgo run my_example --release
```

---

## Environment Variables

CCGO respects the following environment variables:

| Variable | Description |
|----------|-------------|
| `CCGO_HOME` | CCGO home directory (default: ~/.ccgo) |
| `ANDROID_HOME` | Android SDK path |
| `ANDROID_NDK` | Android NDK path |
| `OHOS_SDK_HOME` | OpenHarmony SDK path |
| `CCGO_CMAKE_DIR` | Custom CMake scripts directory |
| `NO_COLOR` | Disable colored output |

---

## Exit Codes

| Code | Meaning |
|------|---------|
| 0 | Success |
| 1 | General error |
| 2 | Configuration error |
| 3 | Build error |
| 4 | Dependency error |
| 101 | User cancelled operation |

---

## Getting Help

```bash
# Get help for any command
ccgo <command> --help

# Examples
ccgo build --help
ccgo publish --help
```

For more information, see:
- [CCGO.toml Reference]ccgo-toml.md
- [Build System]../features/build-system.md
- [Dependency Management]../features/dependency-management.md