aboutsummaryrefslogtreecommitdiffstats
path: root/src/_conan
blob: 6f8e0fffb733dab327f2c84101a2adb888047f35 (plain) (blame)
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
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
#compdef conan
# ------------------------------------------------------------------------------
# Copyright (c) 2010-2017 Github zsh-users - https://github.com/zsh-users
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#     * Redistributions of source code must retain the above copyright
#       notice, this list of conditions and the following disclaimer.
#     * Redistributions in binary form must reproduce the above copyright
#       notice, this list of conditions and the following disclaimer in the
#       documentation and/or other materials provided with the distribution.
#     * Neither the name of the zsh-users nor the
#       names of its contributors may be used to endorse or promote products
#       derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# ------------------------------------------------------------------------------
# Description
# -----------
#
#  Completion script for conan 2.29.1 (https://conan.io).
#
# ------------------------------------------------------------------------------
# Authors
# -------
#
#  * Julien Nicoulaud <julien.nicoulaud@gmail.com>
#  * Shohei Yoshida <https://github.com/syohex>
#
# ------------------------------------------------------------------------------

_conan() {
  local context state state_descr line ret=1
  typeset -A opt_args

  local -a conan_common_options=(
    '(- *)'{-h,--help}'[show help message and exit]'
    '-v[verbose output]'
    '-vquiet[verbose level quiet]'
    '-verror[verbose level error]'
    '-vwarning[verbose level warning]'
    '-vnotice[verbose level notice]'
    '-vstatus[verbose level status]'
    '-vverbose[verbose level verbose]'
    '-vv[more verbose output]'
    '-vdebug[verbose level debug]'
    '-vvv[more and more verbose output]'
    '-vtrace[verbose level trace]'
    '--out-file[write the output of the command to the specified file instead of stdout]:file:_files'
    \*{-cc,--core-conf}'[define core configuration, overwriting global.conf values]:value'
  )

  local -a conan_reference_options=(
    '--name[provide a package name if not specified in conanfile]:name'
    '--version[provide a package version if not specified in conanfile]:version'
    '--user[provide a user if not specified in conanfile]:user'
    '--channel[provide a channel if not specified in conanfile]:channel'
  )

  local -a conan_profile_options=(
    '(-pr --profile)'{-pr,--profile}'[apply the specified profile]:profile'
    '(-pr\:b --profile\:build)'{-pr\\:b,--profile\\:build}'[apply the specified profile build]:profile_build'
    '(-pr\:h --profile\:host)'{-pr\\:h,--profile\\:host}'[apply the specified profile host]:profile_host'
    '(-pr\:a --profile\:all)'{-pr\\:a,--profile\\:all}'[apply the specified profile all]:profile_all'
    '(-o --options)'{-o,--options}'[apply the specified options]:options'
    '(-o\:b --options\:build)'{-o\\:b,--options\\:build}'[apply the specified options build]:options_build'
    '(-o\:h --options\:host)'{-o\\:h,--options\\:host}'[apply the specified options host]:options_host'
    '(-o\:a --options\:all)'{-o\\:a,--options\\:all}'[apply the specified options all]:options_all'
    '(-s --settings)'{-s,--settings}'[apply the specified settings]:settings'
    '(-s\:b --settings\:build)'{-s\\:b,--settings\\:build}'[apply the specified settings build]:settings_build'
    '(-s\:h --settings\:host)'{-s\\:h,--settings\\:host}'[apply the specified settings host]:settings_host'
    '(-s\:a --settings\:all)'{-s\\:a,--settings\\:all}'[apply the specified settings all]:settings_all'
    '(-c --conf)'{-c,--conf}'[apply the specified conf]:conf'
    '(-c\:b --conf\:build)'{-c\\:b,--conf\\:build}'[apply the specified conf build]:conf_build'
    '(-c\:h --conf\:host)'{-c\\:h,--conf\\:host}'[apply the specified conf host]:conf_host'
    '(-c\:a --conf\:all)'{-c\\:a,--conf\\:all}'[apply the specified conf all]:conf_all'
  )

  local -a conan_lockfile_options=(
    '(-l --lockfile)'{-l,--lockfile}'[path to a lockfile]: :_files'
    '--lockfile-partial[do not raise an error if some dependency is not found in lockfile]'
    '--lockfile-out[filename of the updated lockfile]: :_files'
    '--lockfile-clean[remove unused entries from the lockfile]'
    '*--lockfile-overrides[overwrite lockfile overrides]:overrides'
  )

  local -a conan_remote_options=(
    '(-r --remote -nr --no-remote)'{-r,--remote}'[look in the specified remote server]:remote'
    '(-r --remote -nr --no-remote)'{-nr,--no-remote}'[do not use remote, resolve exclusively in the cache]'
    \*{-u,--update}'[will install newer versions for the given references]:update'
  )

  _arguments -C \
    '(- : *)'{-h,--help}'[display help information]' \
    '(- : *)'{-v,--version}'[display version information]' \
    '(-h --help)1: :_conan_commands' \
    '(-h --help)*:: :->command_args' \
    && ret=0

  case $state in
    command_args)
      if (( $+functions[_conan_${words[1]}] )); then
        _call_function ret _conan_${words[1]} && ret=0
      fi
    ;;
  esac

  return ret
}

(( $+functions[_conan_commands] )) ||
_conan_commands() {
  local -a commands=(
    # consumer commands
    'cache:perform file operations in the local cache'
    'config:manages conan configuration information'
    'graph:obtain information about the dependency graph without fetching binaries'
    'inspect:inspect a conanfile.py to return its public fields'
    'install:installs the requirements specified in a "conanfile.py" or "conanfile.txt"'
    'list:list recipes, revisions or packages in the cache or the remotes'
    'lock:create or manage lockfiles'
    'pkglist:Several operations over package lists'
    'profile:manage profiles'
    'remote:manage the remote list and the users authenticated on them'
    'remove:remove recipes or packages from local cache or a remote'
    'require:Add/remove requirements to/from your local cananfile'
    'run:run a command given a set of requirements from a recipe or command line'
    'search:search for package recipes in all the remotes or a remote'
    'version:give information about the Conan client version'
    'workspace:manage Conan workspaces'

    # creator commands
    'build:install dependencies and call the build() method'
    'create:create a package'
    'download:download(without installing) a single conan package from a remote server'
    'editable:allow working with a package that resides in user folder'
    'export:export a recipe to the Conan package cache'
    'export-pkg:create a package directly from pre-compiled binaries'
    'new:create a new example recipe and source files from a template'
    'source:call the source() method'
    'test:test a package from a test_package folder'
    'upload:upload packages to a remote'

    # security commands
    'audit:find vulnerabilities in your dependencies'
    'report:get information about the recipe and its sources'
  )

  _describe -t 'subcommands' 'subcommands' commands
}

#
# consumer commands
#

(( $+functions[_conan_cache] )) ||
_conan_cache() {
  local curcontext=$curcontext state state_descr line ret=1
  typeset -A opt_args

  _arguments -C \
    $conan_common_options[@] \
    '1:subcommand:->subcommand' \
    '*:: :->args' \
    && ret=0

  case $state in
    (subcommand)
      local -a commands=(
        'backup-upload:upload all the source backups present in the cache'
        'check-integrity:check the integrity of the local cache for the given references'
        'clean:remove non-critical folders from the cache'
        'path:show the path to the Conan cache for a given reference'
        'ref:show the reference for a given Conan cache folder'
        'restore:put the artifacts from an archive into the cache'
        'save:get the artifacts from a package list and archive them'
        'sign:sign packages with the Package Signing Plugin'
        'verify:check the signature of packages with the Package Signing Plugin'
      )
      _describe -t 'commands' "command" commands && ret=0
      ;;
    (args)
      local -a opts=($conan_common_options[@])
      case $words[1] in
        (check-integrity|sign|verify)
          opts+=(
            '(-f --format)'{-f,--format}'[select the output format]:format:(json)'
            '(-l --list)'{-l,--list}'[package list of packages to check integrity for]:list'
            \*{-p,--package-query}'[only the packages matching a specific query]:query'
            '1:pattern'
          )
          ;;
        (clean)
          opts+=(
            '(-l --list)'{-l,--list}'[package list of packages to clean]:list'
            '(-s --source)'{-s,--source}'[clean source folders]'
            '(-b --build)'{-b,--build}'[clean build folders]'
            '(-d --download)'{-d,--download}'[clean download folders]'
            '(-t --temp)'{-t,--temp}'[clean temporary folders]'
            '(-bs --backup-sources)'{-bs,--backup-sources}'[clean backup sources]'
            \*{-p,--package-query}'[remove only the packages matching a specific query]:query'
            '1:pattern'
          )
          ;;
        (path)
          opts+=(
            '--folder[path to show]::type:(export_source source build metadata)' \
            '1:recipe_or_package_reference:_files'
          )
          ;;
        (ref)
          opts+=(
            '1:folder:_files -/'
          )
          ;;
        (restore)
          opts+=(
            '1:path:_files'
          )
          ;;
        (save)
          opts+=(
            '(-f --format)'{-f,--format}'[select the output format]:format:(json)'
            '(-l --list)'{-l,--list}'[package list of packages to check integrity for]:list'
            '--file[save to this file]:file:_files -g "*.(tgz|txz|tzst)"'
            '--no-source[exclude the sources]'
            '1:pattern'
          )
          ;;
      esac

      _arguments "$opts[@]" && ret=0
    ;;
  esac

  return ret
}

(( $+functions[_conan_config] )) ||
_conan_config() {
  local curcontext=$curcontext state state_descr line ret=1
  typeset -A opt_args

  _arguments -C \
    '(- : *)'{-h,--help}'[display help information]' \
    '1: :->subcommand' \
    '*:: :->args' \
    && ret=0

  case $state in
    (subcommand)
      local -a commands=(
        'clean:clean the configuration files in the Conan home folder'
        'home:show the Conan home folder'
        'install:install the configuration into the Conan home folder'
        'install-pkg:install the configuration from a Conan package or a conanconfig.yml file'
        'list:show all the Conan available configurations, core and tools'
        'show:get the value of the specified conf'
      )
      _describe -t 'commands' "command" commands && ret=0
      ;;
    (args)
      local -a opts=($conan_common_options[@])
      case $words[1] in
        (install)
          opts+=(
            '--verify-ssl[Verify SSL connection when downloading file]: :(True False)'
            '(-t --type)'{-t,--type}'[Type of remote config]: :(git dir file url)'
            \*{-a,--args}'[String with extra arguments for "git clone"]:arg'
            \*{-sf,--source-folder}'[Install files only from a source subfolder from specified origin]: :_files -/'
            '(-tf --target-folder)'{-tf,--target-folder}'[Install to that path in the conan cache]: :_files -/'
            '*:item:_files'
          )
          ;;
        (install-pkg)
          opts+=(
            '(-l --lockfile)'{-l,--lockfile}'[path to a lockfile]:file:_files'
            '--lockfile-partial[do not raise an error if some dependency is not found in lockfile]'
            '--lockfile-out[file name of the updated lockfile]:file:_files'
            '(-f --force)'{-f,--force}'[force the re-installation of configuration]'
            '--insecure[allow insecure server connections when using SSL]'
            '--url[provide Conan repository URL]:url'
            '(-pr --profile)'{-pr,--profile}'[profile to install config]:profile'
            '(-s --settings)'{-s,--settings}'[settings to install config]:settings'
            '(-o --options)'{-o,--options}'[options to install config]:options'
            '*:package_reference'
          )
          ;;
        (list|show)
          opts+=(
            '(-f --format)'{-f,--format}'[select the output format]:format:(json)'
            '*:pattern'
          )
          ;;
      esac

      _arguments "$opts[@]" && ret=0
    ;;
  esac

  return ret
}

(( $+functions[_conan_graph] )) ||
_conan_graph() {
  local curcontext=$curcontext state state_descr line ret=1
  typeset -A opt_args

  _arguments -C \
    '1:subcommand:->subcommand' \
    '*:: :->args' \
    && ret=0

  case $state in
    (subcommand)
      local -a commands=(
        'build-order:compute the build order of a dependency graph'
        'build-order-merge:merge more than 1 build-order file'
        'explain:explain what is wrong with the dependency graph'
        'info:compute the dependency graph and shows information about it'
        'outdated:list the dependencies in the graph and it is newer versions in the remote'
      )
      _describe -t 'commands' "command" commands && ret=0
      ;;
    (args)
      local -a opts=($conan_common_options[@])
      case $words[1] in
        (build-order|explain|info|outdated)
          opts+=(
            \*{-b,--build}'[optional, specify which packages to build from source]:build'
            '--requires[directly provide requires instead of a conanfile]:requires'
            '--tool-requires[directly provide tool-requires instead of a conanfile]:tool-requires'
            $conan_remote_options[@]
            $conan_profile_options[@]
            $conan_reference_options[@]
            $conan_lockfile_options[@]
            '*:folder:_files -/'
          )
          ;|
        (explain|info|outdated)
          opts+=(
            '--check-updates[check if there are recipe updates]'
            '--build-require[whether the provided reference is a build-require]'
          )
          ;;
        (build-order)
          opts+=(
            '--order-by[select how to order the output(default "recipe")]:type:(recipe configuration)'
            '--reduce[reduce the build order, output only those to build]'
          )
          ;;
        (explain)
          opts+=(
            '*--missing[a pattern in the form "pkg/version#revision:package_id#revision"]:pattern'
          )
          ;;
        (info)
          opts+=(
            '*--filter[show only the specified fields]:pattern'
            '*--package-filter[print information only for packages that match the patterns]:pattern'
            '(-d --deployer)'{-d,--deployer}'[deploy using the provided deployer to the output folder]:deployer:(full_deploy direct_deploy)'
            '(-df --deployer-folder)'{-df,--deployer-folder}'[deployer output folder]:folder:_files -/'
            '*:path:_files'
          )
          ;;
        (build-order-merge)
          opts+=(
            '(-f --format)'{-f,--format}'[select the output format]:format:(json html)'
            '*--file[files to be merged]:file:_files'
            '--reduce[reduce the build order, output only those to build]'
          )
          ;;
      esac

      _arguments "$opts[@]" && ret=0
    ;;
  esac

  return ret
}

(( $+functions[_conan_inspect] )) ||
_conan_inspect() {
  local ret=1

  _arguments \
    $conan_common_options[@] \
    '(-f --format)'{-f,--format}'[select the output format]:format:(json)' \
    '(-r --remote -nr --no-remote)'{-r,--remote}'[remote names. Accepts wildcards("*")]:remote' \
    '(-r --remote -nr --no-remote)'{-nr,--no-remote}'[do not use remote]' \
    '(-l --lockfile)'{-l,--lockfile}'[path to a lockfile]:path:_files' \
    '--lockfile-partial[do not raise an error if some dependency is not found in lockfile]' \
    '*:recipe_folder:_files -/' \
    && ret=0

  return ret
}

(( $+functions[_conan_install] )) ||
_conan_install() {
  local ret=1
  local -a generators=(
    cmake cmake_multi cmake_paths cmake_find_package cmake_find_package_multi
    msbuild visual_studio visual_studio_multi visual_studio_legacy xcode compiler_args gcc
    boost-build b2 qbs qmake scons pkg_config virtualenv virtualenv_python virtualbuildenv
    virtualrunenv youcompleteme txt json premake make markdown deploy
  )
  local -a opts=(
    $conan_common_options[@]
    '(-f --format)'{-f,--format}'[select the output format]:format:(json)'
    \*{-b,--build}'[optional, specify which packages to build from source]:build'
    '--requires[directly provide requires instead of a conanfile]:requires'
    '--tool-requires[directly provide tool-requires instead of a conanfile]:tool-requires'
    '(-g --generator)'{-g,--generator}'[generators to use]:generator:($generators)'
    '(-of --output-folder)'{-of,--output-folder}'[the root output folder for generated and build files]:dir:_files -/'
    '(-d --deployer)'{-d,--deployer}'[deploy using the provided deployer to the output folder]:deployer:(full_deploy direct_deploy runtime_deploy)'
    '--deployer-folder[deployer output folder]:folder:_files -/'
    '*--deployer-package[execute the deploy() method of the packages matching the provided patterns]:pattern'
    '--build-require[whether the provided path is a build-require]'
    '--envs-generation[generation strategy for virtual environment files for the root]:bool:(false)'
    $conan_remote_options[@]
    $conan_profile_options[@]
    $conan_lockfile_options[@]
    '1:recipe_dir_or_conanfile:_files'
  )

  _arguments "$opts[@]" && ret=0
  return ret
}

(( $+functions[_conan_list] )) ||
_conan_list() {
  local ret=1
  local -a opts=(
    $conan_common_options[@]
    '(-f --format)'{-f,--format}'[select the output format]:format:(json html compact)'
    \*{-p,--package-query}'[remove only the packages matching a specific query]:query'
    \*{-fp,--filter-profile}'[profiles to filter the binaries]:filter_profile'
    \*{-fs,--filter-settings}'[settings to filter the binaries]:filter_settings'
    \*{-fo,--filter-options}'[options to filter the binaries]:filter_options'
    '(-r --remote)'{-r,--remote}'[remote names]:remote'
    '(-c --cache)'{-c,--cache}'[search in the local cache]'
    '(-g --graph)'{-g,--graph}'[graph json file]:file:_files'
    '(-gb --graph-binaries)'{-gb,--graph-binaries}'[which binaries are listed]:graph_binaries'
    '(-gr --graph-recipes)'{-gr,--graph-recipes}'[which recipes are listed]:graph_recipes'
    '(-gc --graph-context)'{-gc,--graph-context}'[filter the results by the given context]:context:(build host build-only host-only)'
    '--lru[list recipes and binaries that have not been recently used]:lru'
    '1:recipe_or_package_reference:_files'
  )

  _arguments "$opts[@]" && ret=0
  return ret
}

(( $+functions[_conan_lock] )) ||
_conan_lock() {
  local curcontext=$curcontext state state_descr line ret=1
  typeset -A opt_args

  _arguments -C \
    '(- : *)'{-h,--help}'[display help information]' \
    '1:subcommand:->subcommand' \
    '*:: :->args'

  case $state in
    (subcommand)
      local -a commands=(
        'add:add requires, build-requires or python requires to an existing or new lockfile'
        'create:create a lockfile from a conanfile or a reference'
        'merge:merge 2 or more lockfiles'
        'remove:remove requires, build-requires or python-requires from an existing lockfile'
        'update:update requires'
        'upgrade:upgrade requires, build-requires or python-requires from an exiting lockfile'
        'upgrade-config:upgrade config requires in a lockfile'
      )
      _describe -t 'commands' "command" commands && ret=0
      ;;
    (args)
      local -a opts=($conan_common_options)
      case $words[1] in
        (add)
          opts+=(
            '*--requires[add references to lockfile]:requires'
            '*--build-requires[add build-requires to lockfile]:build_requires'
            '*--python-requires[add python-requires to lockfile]'
            '--lockfile-out[file name of the created lockfile]:filename:_files'
            '--lockfile[file name of the input lockfile]:filename:_files'
          )
          ;;
        (create)
          opts+=(
            \*{-b,--build}'[optional, specify which packages to build from source]:build'
            '--requires[directly provide requires instead of a conanfile]:requires'
            '--tool-requires[directly provide tool-requires instead of a conanfile]:tool-requires'
            '--build-require[whether the provided reference is a build-require]'
            $conan_remote_options[@]
            $conan_profile_options[@]
            $conan_reference_options[@]
            $conan_lockfile_options[@]
            '1: :_files'
          )
          ;;
        (merge)
          opts+=(
            '--lockfile[file name of the input lockfile]:filename:_files'
            '--lockfile-out[file name of the created lockfile]:filename:_files'
          )
          ;;
        (remove)
          opts+=(
            '*--build-requires[remove build-requires from lockfile]:build_requires'
            '*--python-requires[remove python-requires from lockfile]'
            '*--config-requires[remove config-requires from lockfile]'
            '--lockfile-out[file name of the created lockfile]:filename:_files'
            '--lockfile[file name of the input lockfile]:filename:_files'
          )
          ;;
        (update)
          opts+=(
            '*--requires[update references to lockfile]:requires'
            '*--build-requires[update build-requires from lockfile]:build_requires'
            '*--python-requires[update python-requires from lockfile]'
            '*--config-requires[update config-requires from lockfile]'
            '--lockfile-out[file name of the created lockfile]:filename:_files'
            '--lockfile[file name of the input lockfile]:filename:_files'
          )
          ;;
        (upgrade)
          opts+=(
            '--requires[directly provide requires instead of a conanfile]:requires'
            '--tool-requires[directly provide tool-requires instead of a conanfile]:tool-requires'
            \*{-ur,--update-requires}'[update requires from lockfile]:update_requires'
            \*{-ubr,--update-build-requires}'[update build-requires from lockfile]:update_build_requires'
            \*{-upr,--update-python-requires}'[update python-requires from lockfile]:update_python_requires'
            '*--build-requires[update build-requires from lockfile]:build_requires'
            $conan_remote_options[@]
            $conan_profile_options[@]
            $conan_reference_options[@]
            $conan_lockfile_options[@]
            '*:path:_files'
          )
          ;;
        (upgrade-config)
          opts+=(
            '--requires[directly provide requires instead of a conanfile]:requires'
            '--tool-requires[directly provide tool-requires instead of a conanfile]:tool-requires'
            '*--update-config-requires[update config-requires from lockfile]:update_config_requires'
            $conan_remote_options[@]
            $conan_profile_options[@]
            $conan_reference_options[@]
            $conan_lockfile_options[@]
            '*:path:_files'
          )
          ;;
      esac

      _arguments "$opts[@]" && ret=0
      ;;
  esac

  return ret
}

(( $+functions[_conan_profile] )) ||
_conan_profile() {
  local curcontext=$curcontext state state_descr line ret=1
  typeset -A opt_args

  _arguments -C \
    '(- : *)'{-h,--help}'[display help information]' \
    '1:subcommand:->subcommand' \
    '*:: :->args' \
    && ret=0

  case $state in
    (subcommand)
      local -a commands=(
        'detect:generate a profile using auto-detected values'
        'list:list all profiles in the cache'
        'path:show profile path location'
        'show:show aggregated profiles from the passed arguments'
      )
      _describe -t 'commands' "command" commands && ret=0
      ;;
    (args)
      local opts=($conan_common_options[@])
      case $words[1] in
        (detect)
          opts+=(
            '--name[profile name, "default" if not specified]::name'
            '(-f --force)'{-f,--force}'[overwrite if exists]'
            '(-e --exist-ok)'{-e,--exist-ok}'[if the profile already exist, do not detect a new one]'
          )
          ;;
        (list)
          opts+=(
            '(-f --format)'{-f,--format}'[select the output format]:format:(json)'
          )
          ;;
        (path)
          opts+=('*:name')
          ;;
        (show)
          opts+=(
            '(-cx --context)'{-cx,--context}'[context to profile]:context:(host build)'
            $conan_profile_options[@]
          )
          ;;
      esac

      _arguments "$opts[@]" && ret=0
    ;;
  esac

  return ret
}

(( $+functions[_conan_remote] )) ||
_conan_remote() {
  local curcontext=$curcontext state state_descr line ret=1
  typeset -A opt_args

  _arguments -C \
    $conan_common_options[@] \
    '1:subcommand:->subcommand' \
    '*:: :->args' \
    && ret=0

  case $state in
    (subcommand)
      local -a commands=(
        'add:add a remote'
        'auth:authenticate in the defined remotes'
        'disable:disable all the remotes matching a pattern'
        'enable:enable all the remotes matching a pattern'
        'list:list current remotes'
        'list-users:list the users logged into all the remotes'
        'login:login into the specified remotes matching a pattern'
        'logout:clear the existing credentials for the specified remotes matching a pattern'
        'remove:remove a remote'
        'rename:rename a remote'
        'set-user:associate a username with a remote matching pattern without performing the authentication'
        'update:update a remote'
      )
      _describe -t 'commands' "command" commands && ret=0
    ;;
    (args)
      local -a opts=($conan_common_options[@])
      case $words[1] in
        (add)
          opts+=(
            '--insecure[allow insecure server connections when using SSL]'
            '--index[insert the remote at a specific position in the remote list]:index'
            '(-f --force)'{-f,--force}'[force the definition of the remote even if duplicated]'
            \*{-ap,--allowed-packages}'[add recipe reference pattern to list of allowed packages]:allowed_packages'
            '(-t --type)'{-t,--type}'[define the remote type]:type:(local-recipes-index)'
            '--recipes-only[disallow binary downloads from this remote, only recipes will be downloaded]'
            '1:name'
            '2:url'
          )
          ;;
        (auth)
          opts+=(
            '--with-user[only try to auth in those remotes that already have a user name]'
            '--force[force authentication for anonymous-enabled repositories]'
            '--strict[return exit code 1 if authentication fails for any remote]'
            '1:remote:_conan_remotes'
          )
          ;;
        (list|list-users)
          opts+=('(-f --format)'{-f,--format}'[select the output format]:format:(json)')
          ;;
        (login)
          opts+=(
            '(-f --format)'{-f,--format}'[select the output format]:format:(json)'
            '(-p --password)'{-p,--password}'[user password]:password'
            '1:remote:_conan_remotes'
            '2:username'
          )
          ;;
        (logout)
          opts+=(
            '(-f --format)'{-f,--format}'[select the output format]:format:(json)'
            '1:remote:_conan_remotes'
          )
          ;;
        (remove)
          opts+=('1:remote:_conan_remotes')
          ;;
        (rename)
          opts+=(
            '1:remote:_conan_remotes'
            '2:new_name'
          )
          ;;
        (set-user)
          opts+=(
            '(-f --format)'{-f,--format}'[select the output format]:format:(json)'
            '1:remote:_conan_remotes'
            '2:user_name'
          )
          ;;
        (update)
          opts+=(
            '--url[new url for the remote]:url'
            '--secure[do not allow insecure server connections when using SSL]'
            '--insecure[allow insecure server connections when using SSL]'
            '--index[insert the remote at a specific position in the remote list]:index'
            \*{-ap,--allowed-packages}'[add recipe reference pattern to list of allowed packages]:allowed_packages'
            '--recipes-only[disallow binary downloads from this remote, only recipes will be downloaded]:bool:(True False)'
            '1:remote:_conan_remotes'
          )
          ;;
      esac

      _arguments "${opts[@]}" && ret=0
      ;;
  esac

  return ret
}

(( $+functions[_conan_remove] )) ||
_conan_remove() {
  local ret=1
  local -a opts=(
    $conan_common_options[@]
    '(-f --format)'{-f,--format}'[select the output format]:format:(json)'
    '(-c --confirm)'{-c,--confirm}'[remove without requesting a confirmation]'
    \*{-p,--package-query}'[remove only the packages matching a specific query]:query'
    \*{-r,--remote}'[will remove from the specified remote]:remote'
    \*{-l,--list}'[package list file]:list:_files'
    '--lru[remove recipes and binaries that have not been recently used]:lru'
    '--dry-run[do not remove any items, only print those which would be removed]'
    '*:recipe_or_package_reference:_files'
  )

  _arguments "$opts[@]" && ret=0
  return ret
}

(( $+functions[_conan_search] )) ||
_conan_search() {
  local ret=1
  local -a opts=(
    $conan_common_options[@]
    '(-f --format)'{-f,--format}'[select the output format]:format:(json)'
    \*{-r,--remote}'[will remove from the specified remote]:remote'
    '*:recipe_reference:_files'
  )

  _arguments "$opts[@]" && ret=0
  return ret
}

(( $+functions[_conan_version] )) ||
_conan_version() {
  local ret=1
  _arguments \
    $conan_common_options[@] \
    '(-f --format)'{-f,--format}'[select the output format]:format:(json)' \
    && ret=0

  return ret
}

#
# creator commands
#

(( $+functions[_conan_build] )) ||
_conan_build() {
  local ret=1

  local -a opts=(
    $conan_common_options[@]
    \*{-g,--generator}'[generators to use]:generator'
    '(-of --output-folder)'{-of,--output-folder}'[root output folder for generated and build files]:folder:_files -/'
    '(-d --deployer)'{-d,--deployer}'[deploy using the provided deployer to the output folder]:deployer:(full_deploy direct_deploy)'
    '(-df --deployer-folder)'{-df,--deployer-folder}'[deployer output folder]:folder:_files -/'
    '--build-require[whether the provided reference is a build-require]'
    '--envs-generation[generation strategy for virtual environment files for the root]:flag:(false)'
    \*{-b,--build}'[optional, specify which packages to build from source]:build'
    $conan_reference_options[@]
    $conan_remote_options[@]
    $conan_profile_options[@]
    $conan_lockfile_options[@]
    '*: :_files'
  )

  _arguments "$opts[@]" && ret=0
  return ret
}

(( $+functions[_conan_create] )) ||
_conan_create() {
  local ret=1
  local -a opts=(
    $conan_common_options[@]
    \*{-b,--build}'[optional, specify which packages to build from source]:build'
    '(-u --update)'{-u,--update}'[will check the remote and in case a newer version]'
    '--build-require[whether the provided reference is a build-require]'
    '(-tf --test-folder)'{-tf,--test-folder}'[alternative test folder name]:folder:_files -/'
    $conan_reference_options[@]
    $conan_lockfile_options[@]
    $conan_remote_options[@]
    $conan_profile_options[@]
    '*: :_files -/'
  )

  _arguments "$opts[@]" && ret=0
  return ret
}

(( $+functions[_conan_download] )) ||
_conan_download() {
  local ret=1
  local -a opts=(
    $conan_common_options[@]
    '--only-recipe[download only the recipe, not the binary packages]'
    \*{-p,--package-query}'[only download packages matching a specific query]:query'
    '(-r --remote)'{-r,--remote}'[download from the specific remote]:remote:_conan_remotes'
    '(-m --metadata)'{-m,--metadata}'[download the metadata matching the pattern]:pattern'
    '(-l --list)'{-l,--list}'[package list file]:list:_files'
    '*:recipe_or_package_reference:_files'
  )

  _arguments "$opts[@]" && ret=0
  return ret
}

(( $+functions[_conan_editable] )) ||
_conan_editable() {
  local curcontext=$curcontext state state_descr line ret=1
  typeset -A opt_args

  _arguments -C \
    $conan_common_options[@] \
    '1:subcommand:->subcommand' \
    '*:: :->args' \
    && ret=0

  case $state in
    (subcommand)
      local -a commands=(
        'add:define the given path location as the package reference'
        'list:list all the packages in editable mode'
        'remove:remove the editable mode for this reference'
      )
      _describe -t 'commands' "command" commands && ret=0
    ;;
    (args)
      local opts=($conan_common_options[@])
      case $words[1] in
        (add)
          opts+=(
            '(-of --output-folder)'{-of,--output-folder}'[the root output folder]:folder:_files -/'
            '(-r --remote -nr --no-remote)'{-r,--remote}'[look in the specified remote server]:remote'
            '(-r --remote -nr --no-remote)'{-nr,--no-remote}'[do not use remote]'
            $conan_reference_options[@]
            '*:folder:_files -/'
          )
          ;;
        (list)
          opts+=('(-f --format)'{-f,--format}'[select the output format]:format:(json)')
          ;;
        (remove)
          opts+=(
            '(-r --refs)'{-r,--refs}'[directly provide reference patterns]:refs'
            '*:folder:_files -/'
          )
          ;;
      esac

      _arguments "$opts[@]" && ret=0
    ;;
  esac

  return ret
}

(( $+functions[_conan_export] )) ||
_conan_export() {
  local ret=1
  local -a opts=(
    $conan_common_options[@]
    '(-f --format)'{-f,--format}'[select output format]:format:(json pkglist)'
    '(-r --remote -nr --no-remote)'{-r,--remote}'[remote names. Accepts wildcards("*")]:remote'
    '(-r --remote -nr --no-remote)'{-nr,--no-remote}'[do not use remote]'
    '(-l --lockfile)'{-l,--lockfile}'[path to a lockfile]:file:_files'
    '--lockfile-out[file name of the updated lockfile]:file:_files'
    '--lockfile-partial[do not raise an error if some dependency is not found in lockfile]'
    '--build-require[whether the provided reference is a build-require]'
    $conan_reference_options[@]
    '*: :_files -/'
  )

  _arguments "$opts[@]" && ret=0
  return ret
}

(( $+functions[_conan_export-pkg] )) ||
_conan_export-pkg() {
  local ret=1
  local -a opts=(
    $conan_common_options[@]
    '(-of --output-folder)'{-of,--output-folder}'[root output folder for generated and build files]:folder:_files -/'
    '--build-require[whether the provided reference is a build-require]'
    '(-tf --test-folder)'{-tf,--test-folder}'[alternative test folder name]:folder:_files -/'
    '(-sb --skip-binaries)'{-sb,--skip-binaries}'[skip installing dependencies binaries]'
    '(-r --remote -nr --no-remote)'{-r,--remote}'[look in the specified remote or remote servers]:remote'
    '(-r --remote -nr --no-remote)'{-nr,--no-remote}'[do not use remote]'
    $conan_reference_options[@]
    $conan_lockfile_options[@]
    $conan_profile_options[@]
    '*: :_files -/'
  )

  _arguments "$opts[@]" && ret=0
  return ret
}

(( $+functions[_conan_require] )) ||
_conan_require() {
  local curcontext=$curcontext state state_descr line ret=1
  typeset -A opt_args

  _arguments -C \
    $conan_common_options[@] \
    '1: :->subcommand' \
    '*:: :->args' \
    && ret=0

  case $state in
    (subcommand)
      local -a commands=(
        'add:add a new requirement to your local conanfile as a version range'
        'remove:removes a requirement from your local conanfile'
      )
      _describe -t 'commands' "command" commands && ret=0
      ;;
    (args)
      local -a common_options=(
        '--folder[path to a folder containing a recipe(conanfile.py)]:folder:_files -/'
        '(-tor --tool)'{-tor,--tool}'[tool requirement name]:name'
        '(-ter --test)'{-ter,--test}'[test requirement name]:name'
      )

      case $words[1] in
        (add)
          _arguments \
            $conan_common_options[@] \
            $common_options[@] \
            '(-r --remote -nr --no-remote)'{-r,--remote}'[remote names. Accepts wildcards("*")]:remote' \
            '(-r --remote -nr --no-remote)'{-nr,--no-remote}'[do not use remote]' \
            '*::requires' \
            && ret=0
          ;;
        (remove)
          _arguments \
            $conan_common_options[@] \
            $common_options[@] \
            '*::name' \
            && ret=0
          ;;
      esac
      ;;
  esac

  return ret
}

(( $+functions[_conan_new] )) ||
_conan_new() {
  local ret=1
  local -a templates=(
    basic cmake_lib cmake_exe header_lib meson_lib meson_exe msbuild_lib msbuild_exe
    bezel_lib bezel_exe autotools_lib autotools_exe premake_lib premake_exe
    local_recipes_index workspace
  )
  local -a opts=(
    $conan_common_options[@]
    \*{-d,--define}'[define a template argument as key=value]:key_value'
    '(-f --force)'{-f,--force}'[overwrite file if it already exists]'
    '(-o --output)'{-o,--output}'[output folder for the generated files]:folder:_files -/'
    '1:template:($templates)'
  )

  _arguments "$opts[@]" && ret=0
  return ret
}

(( $+functions[_conan_source] )) ||
_conan_source() {
  local ret=1
  local -a opts=(
    $conan_common_options[@]
    $conan_reference_options[@]
    '1: :_files'
  )

  _arguments "$opts[@]" && ret=0
  return ret
}

(( $+functions[_conan_test] )) ||
_conan_test() {
  local ret=1
  local -a opts=(
    $conan_common_options[@]
    \*{-b,--build}'[optional, specify which packages to build from source]:build'
    $conan_remote_options[@]
    $conan_profile_options[@]
    $conan_lockfile_options[@]
    '1:path:_files -/'
    '2:reference'
  )

  _arguments "$opts[@]" && ret=0
  return ret
}

(( $+functions[_conan_upload] )) ||
_conan_upload() {
  local ret=1
  local -a opts=(
    $conan_common_options[@]
    \*{-p,--package-query}'[only upload packages matching a specific query]:query'
    '(-r --remote)'{-r,--remote}'[upload to this specific remote]:remote:_conan_remotes'
    '--only-recipe[upload only the recipe, not the binary packages]'
    '--force[force the upload of the artifacts]'
    '--check[perform an integrity check before upload]'
    '(-c --confirm)'{-c,--confirm}'[upload all matching recipes without confirmation]'
    '--dry-run[do not execute the real upload]'
    '--allow-disabled[allow uploading to disabled remote]'
    '(-l --list)'{-l,--list}'[package list file]:list:_files'
    '(-m --metadata)'{-m,--metadata}'[upload the metadata]:metadata:_files'
    '1::reference'
  )

  _arguments "$opts[@]" && ret=0
  return ret
}

#
# security commands
#

(( $+functions[_conan_audit] )) ||
_conan_audit() {
  local curcontext=$curcontext state state_descr line ret=1
  typeset -A opt_args

  _arguments -C \
    $conan_common_options[@] \
    '1: :->subcommand' \
    '*:: :->args' \
    && ret=0

  case $state in
    (subcommand)
      local -a commands=(
        'list:list the vulnerabilities of the given reference'
        'provider:manage security providers for the "conan audit" command'
        'scan:scan a given recipe for vulnerabilities in its dependencies'
      )
      _describe -t 'commands' "command" commands && ret=0
      ;;
    (args)
      case $words[1] in
        (list)
          _arguments \
            $conan_common_options[@] \
            '(-f --format)'{-f,--format}'[select the output format]:format:(json html)' \
            '(-l --list)'{-l,--list}'[package list file to list vulnerabilities for]:list:_files' \
            '(-s --sbom)'{-s,--sbom}'[SBOM file to list vulnerabilities for]:sbom:_files' \
            '(-l --lockfile)'{-l,--lockfile}'[path to the lockfile to check for vulnerabilities]:file:_files' \
            '(-r --remote)'{-r,--remote}'[remote to use for listing]:remote' \
            '(-p --provider)'{-p,--provider}'[provider to use for scanning]:provider' \
            '*::reference' \
            && ret=0
          ;;
        (provider)
          _arguments \
            $conan_common_options[@] \
            '(-f --format)'{-f,--format}'[select the output format]:format:(json html)' \
            '--url[provider URL]:url' \
            '--type[provider type]:type:(conan-center-proxy private)' \
            '--token[provider token]:token' \
            '1:action:(add list auth remove)' \
            '*::name' \
            && ret=0
          ;;
        (scan)
          _arguments \
            $conan_common_options[@] \
            \*{-b,--build}'[specify which packages to build from source]:build:(never missing cascade)' \
            '--requires[directly provide requires instead of a conanfile]:requires' \
            '--tool-requires[directly provide tool-requires instead of a conanfile]:tool-requires' \
            '(-sl --severity-level)'{-sl,--severity-level}'[set threshold for severity level to raise an error]:level' \
            '--context[context to scan]:context:(host build)' \
            '(-p --provider)'{-p,--provider}'[provider to use for scanning]' \
            $conan_remote_options[@] \
            $conan_profile_options[@] \
            $conan_reference_options[@] \
            $conan_lockfile_options[@] \
            '*::path:_files' \
            && ret=0
          ;;
      esac
      ;;
  esac

  return ret
}

(( $+functions[_conan_report] )) ||
_conan_report() {
  local curcontext=$curcontext state state_descr line ret=1
  typeset -A opt_args

  _arguments -C \
    $conan_common_options[@] \
    '1: :->subcommand' \
    '*:: :->args' \
    && ret=0

  case $state in
    (subcommand)
      local -a commands=(
        'diff:get the difference between two recipes with their sources'
      )
      _describe -t 'commands' "command" commands && ret=0
      ;;
    (args)
      case $words[1] in
        (diff)
          _arguments \
            $conan_common_options[@] \
            '(-op --old-path)'{-op,--old-path}'[path to the old recipe]:path:_files' \
            '(-or --old-reference)'{-or,--old-reference}'[old reference]:reference' \
            '(-np --new-path)'{-np,--new-path}'[path to the new recipe]:path:_files' \
            '(-nr --new-reference)'{-nr,--new-reference}'[new reference]:reference' \
            '(-r --remote)'{-r,--remote}'[look in the specified remote or remotes server]:remote' \
            && ret=0
          ;;
      esac
      ;;
  esac

  return ret
}

#
# Utilities
#
(( $+functions[_conan_remotes] )) ||
_conan_remotes() {
  local -a remotes=(${${(f)"$(_call_program remotes $service remote list 2>/dev/null)"}%%:*})
  _describe -t remotes 'remote' remotes "$@"
}

(( $+functions[_conan_profiles] )) ||
_conan_profiles() {
  local -a profiles=(${(f)"$(_call_program profiles $service profile list 2>/dev/null)"})
  _describe -t profiles 'profile' profiles "$@"
}

_conan "$@"

# Local Variables:
# mode: Shell-Script
# sh-indentation: 2
# indent-tabs-mode: nil
# sh-basic-offset: 2
# End:
# vim: ft=zsh sw=2 ts=2 et