Default.pm 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. # ------------------------------------------------------------------------------
  2. # (C) Crown copyright Met Office. All rights reserved.
  3. # For further details please refer to the file COPYRIGHT.txt
  4. # which you should have received as part of this distribution.
  5. # ------------------------------------------------------------------------------
  6. use strict;
  7. use warnings;
  8. package Fcm::CLI::Config::Default;
  9. use Fcm::CLI::Option;
  10. use Fcm::CLI::Subcommand;
  11. my %DESCRIPTION_OF = (
  12. # --------------------------------------------------------------------------
  13. BROWSER => <<'END_DESCRIPTION',
  14. If TARGET is specified, it must be a FCM URL keyword, a Subversion URL or the
  15. path to a local working copy. If not specified, the current working directory
  16. is assumed to be a working copy. If the --browser option is specified, the
  17. specified web browser command is used to launch the repository browser.
  18. Otherwise, it attempts to use the default browser from the configuration
  19. setting.
  20. END_DESCRIPTION
  21. # --------------------------------------------------------------------------
  22. BUILD => <<'END_DESCRIPTION',
  23. The path to a CFGFILE may be provided. Otherwise, the build system searches the
  24. default locations for a bld cfg file.
  25. If no option is specified, the options "-s 5 -t all -j 1 -v 1" are assumed.
  26. If the option for full build is specified, the sub-directories created by
  27. previous builds will be removed, so that the current build can start cleanly.
  28. The -s option can be used to limit the actions performed by the build system up
  29. to a named stage. The stages are:
  30. "1", "s" or "setup" - stage 1, setup
  31. "2", "pp" or "pre_process" - stage 2, pre-process
  32. "3", "gd" or "generate_dependency" - stage 3, generate dependency
  33. "4", "gi" or "generate_interface" - stage 4, generate Fortran 9X interface
  34. "5", "m", "make" - stage 5, make
  35. If a colon separated list of targets is specified using the -t option, the
  36. default targets specified in the configuration file will not be used.
  37. If archive mode is switched on, build sub-directories that are only used in the
  38. build process will be archived to TAR files. The default is off.
  39. If specified, the verbose level must be an integer greater than 0. Verbose
  40. level 0 is the quiet mode. Increasing the verbose level will increase the
  41. amount of diagnostic output.
  42. When a build is invoked, it sets up a lock file in the build root directory.
  43. The lock is normally removed at the end of the build. While the lock file is in
  44. place, the build commands invoked in the same root directory will fail. If
  45. you need to bypass this check for whatever reason, you can invoke the build
  46. system with the --ignore-lock option.
  47. END_DESCRIPTION
  48. # --------------------------------------------------------------------------
  49. CFG_PRINTER => <<'END_DESCRIPTION',
  50. If no option is specified, the output will be sent to standard output.
  51. END_DESCRIPTION
  52. # --------------------------------------------------------------------------
  53. EXTRACT => <<'END_DESCRIPTION',
  54. The path to a CFG file may be provided. Otherwise, the extract system searches
  55. the default locations for an ext cfg file.
  56. If no option is specified, the system will attempt an incremental extract where
  57. appropriate.
  58. If specified, the verbose level must be an integer greater than 0. Verbose
  59. level 0 is the quiet mode. Increasing the verbose level will increase the
  60. amount of diagnostic output.
  61. When an extract is invoked, it sets up a lock file in the extract destination
  62. root directory. The lock is normally removed at the end of the extract. While
  63. the lock file is in place, other extract commands invoked in the same
  64. destination root directory will fail. If you need to bypass this check for
  65. whatever reason, you can invoke the extract system with the --ignore-lock
  66. option.
  67. END_DESCRIPTION
  68. # --------------------------------------------------------------------------
  69. EXTRACT_CONFIG_COMPARATOR => <<'END_DESCRIPTION',
  70. Compares the extract configurations of two similar extract configuration files
  71. CFGFILE1 and CFGFILE2.
  72. In normal mode with verbosity level 2 or above, displays the change log of each
  73. revision.
  74. In wiki mode, print revision tables in wiki format. The argument to the --wiki
  75. option must be the Subversion URL or FCM URL keyword of a FCM project
  76. associated with the intended Trac system. The --verbose option has no effect
  77. in wiki mode.
  78. END_DESCRIPTION
  79. # --------------------------------------------------------------------------
  80. GUI => <<'END_DESCRIPTION',
  81. The optional argument PATH modifies the initial working directory of the GUI.
  82. END_DESCRIPTION
  83. # --------------------------------------------------------------------------
  84. KEYWORD => <<'END_DESCRIPTION',
  85. If no argument is specified, prints registered location keywords. Otherwise,
  86. prints the implied location keywords and revision keywords for the specified
  87. target.
  88. END_DESCRIPTION
  89. );
  90. my %OPTION_OF = (
  91. ARCHIVE => Fcm::CLI::Option->new({
  92. name => 'archive',
  93. letter => 'a',
  94. description => 'archives sub-directories on success',
  95. }),
  96. BROWSER => Fcm::CLI::Option->new({
  97. name => 'browser',
  98. letter => 'b',
  99. description => 'specifies the web browser command',
  100. has_arg => Fcm::CLI::Option->SCALAR_ARG,
  101. }),
  102. CLEAN => Fcm::CLI::Option->new({
  103. name => 'clean',
  104. description => 'cleans the destination',
  105. }),
  106. FULL => Fcm::CLI::Option->new({
  107. name => 'full',
  108. letter => 'f',
  109. description => 'runs in full mode',
  110. }),
  111. HELP => Fcm::CLI::Option->new({
  112. name => 'help',
  113. letter => 'h',
  114. description => 'prints help',
  115. is_help => 1,
  116. }),
  117. IGNORE_LOCK => Fcm::CLI::Option->new({
  118. name => 'ignore-lock',
  119. description => 'ignores lock file',
  120. }),
  121. JOBS => Fcm::CLI::Option->new({
  122. name => 'jobs',
  123. letter => 'j',
  124. description => 'number of parallel jobs',
  125. has_arg => Fcm::CLI::Option->SCALAR_ARG,
  126. }),
  127. OUTPUT => Fcm::CLI::Option->new({
  128. name => 'output',
  129. letter => 'o',
  130. description => 'sends output to the specified file',
  131. has_arg => Fcm::CLI::Option->SCALAR_ARG,
  132. }),
  133. STAGE => Fcm::CLI::Option->new({
  134. name => 'stage',
  135. letter => 's',
  136. description => 'runs command up to a named stage',
  137. has_arg => Fcm::CLI::Option->SCALAR_ARG,
  138. }),
  139. TARGETS => Fcm::CLI::Option->new({
  140. name => 'targets',
  141. letter => 't',
  142. delimiter => ':',
  143. description => 'list of build targets, delimited by (:)',
  144. has_arg => Fcm::CLI::Option->ARRAY_ARG,
  145. }),
  146. VERBOSITY => Fcm::CLI::Option->new({
  147. name => 'verbose',
  148. letter => 'v',
  149. description => 'verbose level',
  150. has_arg => Fcm::CLI::Option->SCALAR_ARG,
  151. }),
  152. WIKI => Fcm::CLI::Option->new({
  153. name => 'wiki',
  154. letter => 'w',
  155. description => 'print revision tables in wiki format',
  156. has_arg => Fcm::CLI::Option->SCALAR_ARG,
  157. }),
  158. );
  159. my %SUBCOMMAND_OF = (
  160. BRANCH => Fcm::CLI::Subcommand->new({
  161. names => ['branch', 'br'],
  162. synopsis => 'branch utilities',
  163. invoker_class => 'Fcm::CLI::Invoker::CM',
  164. is_vc => 1,
  165. }),
  166. BROWSER => Fcm::CLI::Subcommand->new({
  167. names => ['trac', 'www'],
  168. synopsis => 'invokes the browser for a version controlled target',
  169. usage => '[OPTIONS...] [TARGET]',
  170. description => $DESCRIPTION_OF{BROWSER},
  171. invoker_class => 'Fcm::CLI::Invoker::Browser',
  172. options => [
  173. $OPTION_OF{BROWSER},
  174. $OPTION_OF{HELP},
  175. ],
  176. }),
  177. BUILD => Fcm::CLI::Subcommand->new({
  178. names => ['build', 'bld'],
  179. synopsis => 'invokes the build system',
  180. usage => '[OPTIONS...] [CFGFILE]',
  181. description => $DESCRIPTION_OF{BUILD},
  182. invoker_class => 'Fcm::CLI::Invoker::ConfigSystem',
  183. invoker_config => {
  184. impl_class => 'Fcm::Build',
  185. cli2invoke_key_map => {
  186. 'archive' => 'ARCHIVE',
  187. 'clean' => 'CLEAN',
  188. 'full' => 'FULL',
  189. 'ignore-lock' => 'IGNORE_LOCK',
  190. 'jobs' => 'JOBS',
  191. 'stage' => 'STAGE',
  192. 'targets' => 'TARGETS',
  193. },
  194. },
  195. options => [
  196. $OPTION_OF{ARCHIVE},
  197. $OPTION_OF{CLEAN},
  198. $OPTION_OF{FULL},
  199. $OPTION_OF{HELP},
  200. $OPTION_OF{IGNORE_LOCK},
  201. $OPTION_OF{JOBS},
  202. $OPTION_OF{STAGE},
  203. $OPTION_OF{TARGETS},
  204. $OPTION_OF{VERBOSITY},
  205. ],
  206. }),
  207. CFG_PRINTER => Fcm::CLI::Subcommand->new({
  208. names => ['cfg'],
  209. synopsis => 'invokes the CFG file pretty printer',
  210. usage => '[OPTIONS...] [CFGFILE]',
  211. description => $DESCRIPTION_OF{CFG_PRINTER},
  212. invoker_class => 'Fcm::CLI::Invoker::CfgPrinter',
  213. options => [
  214. $OPTION_OF{HELP},
  215. $OPTION_OF{OUTPUT},
  216. ],
  217. }),
  218. CM => Fcm::CLI::Subcommand->new({
  219. names => [qw{
  220. add
  221. blame praise annotate ann
  222. cat
  223. checkout co
  224. cleanup
  225. commit ci
  226. copy cp
  227. delete del remove rm
  228. diff di
  229. export
  230. import
  231. info
  232. list ls
  233. lock
  234. log
  235. merge
  236. mkdir
  237. move mv rename ren
  238. propdel pdel pd
  239. propedit pedit pe
  240. propget pget pg
  241. proplist plist pl
  242. propset pset ps
  243. resolved
  244. revert
  245. status stat st
  246. switch sw
  247. unlock
  248. update up
  249. }],
  250. invoker_class => 'Fcm::CLI::Invoker::CM',
  251. is_vc => 1,
  252. }),
  253. CONFLICTS => Fcm::CLI::Subcommand->new({
  254. names => ['conflicts', 'cf'],
  255. synopsis => 'resolves conflicts in your working copy',
  256. usage => '[PATH]',
  257. invoker_class => 'Fcm::CLI::Invoker::CM',
  258. is_vc => 1,
  259. }),
  260. EXTRACT => Fcm::CLI::Subcommand->new({
  261. names => ['extract', 'ext'],
  262. synopsis => 'invokes the extract system',
  263. usage => '[OPTIONS...] [CFGFILE]',
  264. description => $DESCRIPTION_OF{EXTRACT},
  265. invoker_class => 'Fcm::CLI::Invoker::ConfigSystem',
  266. invoker_config => {
  267. impl_class => 'Fcm::Extract',
  268. cli2invoke_key_map => {
  269. 'clean' => 'CLEAN',
  270. 'full' => 'FULL',
  271. 'ignore-lock' => 'IGNORE_LOCK',
  272. },
  273. },
  274. options => [
  275. $OPTION_OF{CLEAN},
  276. $OPTION_OF{FULL},
  277. $OPTION_OF{HELP},
  278. $OPTION_OF{IGNORE_LOCK},
  279. $OPTION_OF{VERBOSITY},
  280. ],
  281. }),
  282. EXTRACT_CONFIG_COMPARATOR => Fcm::CLI::Subcommand->new({
  283. names => ['cmp-ext-cfg'],
  284. synopsis => 'invokes the extract configuration files comparator',
  285. usage => '[OPTIONS...] CFGFILE1 CFGFILE2',
  286. description => $DESCRIPTION_OF{EXTRACT_CONFIG_COMPARATOR},
  287. invoker_class => 'Fcm::CLI::Invoker::ExtractConfigComparator',
  288. options => [
  289. $OPTION_OF{HELP},
  290. $OPTION_OF{VERBOSITY},
  291. $OPTION_OF{WIKI},
  292. ],
  293. }),
  294. GUI => Fcm::CLI::Subcommand->new({
  295. names => ['gui'],
  296. synopsis => 'invokes the GUI wrapper for code management commands',
  297. usage => '[PATH]',
  298. description => $DESCRIPTION_OF{GUI},
  299. invoker_class => 'Fcm::CLI::Invoker::GUI',
  300. }),
  301. HELP => Fcm::CLI::Subcommand->new({
  302. names => ['help', q{?}, q{}],
  303. synopsis => 'displays the usage of this program or its subcommands',
  304. usage => '[SUBCOMMAND]',
  305. description => q{},
  306. invoker_class => 'Fcm::CLI::Invoker::Help',
  307. options => [$OPTION_OF{HELP}],
  308. }),
  309. KEYWORD => Fcm::CLI::Subcommand->new({
  310. names => ['keyword-print', 'kp'],
  311. synopsis => 'prints registered location and/or revision keywords',
  312. usage => '[TARGET]',
  313. description => $DESCRIPTION_OF{KEYWORD},
  314. invoker_class => 'Fcm::CLI::Invoker::KeywordPrinter',
  315. options => [$OPTION_OF{HELP}],
  316. }),
  317. MKPATCH => Fcm::CLI::Subcommand->new({
  318. names => ['mkpatch'],
  319. synopsis => 'creates patches from specified revisions of a URL',
  320. usage => '[OPTIONS] URL [OUTDIR]',
  321. invoker_class => 'Fcm::CLI::Invoker::CM',
  322. is_vc => 1,
  323. }),
  324. );
  325. our @CORE_SUBCOMMANDS = (
  326. $SUBCOMMAND_OF{HELP},
  327. $SUBCOMMAND_OF{BUILD},
  328. $SUBCOMMAND_OF{CFG_PRINTER},
  329. );
  330. our @VC_SUBCOMMANDS = (
  331. $SUBCOMMAND_OF{BRANCH},
  332. $SUBCOMMAND_OF{BROWSER},
  333. $SUBCOMMAND_OF{CONFLICTS},
  334. $SUBCOMMAND_OF{EXTRACT},
  335. $SUBCOMMAND_OF{EXTRACT_CONFIG_COMPARATOR},
  336. $SUBCOMMAND_OF{GUI},
  337. $SUBCOMMAND_OF{KEYWORD},
  338. $SUBCOMMAND_OF{MKPATCH},
  339. $SUBCOMMAND_OF{CM},
  340. );
  341. 1;
  342. __END__
  343. =head1 NAME
  344. Fcm::CLI::Config::Default
  345. =head1 SYNOPSIS
  346. use Fcm::CLI::Config::Default;
  347. @core_subcommands = @Fcm::CLI::Config::Default::CORE_SUBCOMMANDS;
  348. @vc_subcommands = @Fcm::CLI::Config::Default::VC_SUBCOMMANDS;
  349. =head1 DESCRIPTION
  350. This module stores the default configuration of the FCM command line interface.
  351. It should only be used by L<Fcm::CLI::Config|Fcm::CLI::Config>.
  352. =head1 SEE ALSO
  353. L<Fcm::CLI::Config|Fcm::CLI::Config>,
  354. L<Fcm::CLI::Invoker|Fcm::CLI::Invoker>,
  355. L<Fcm::CLI::Subcommand|Fcm::CLI::Subcommand>,
  356. L<Fcm::CLI::Option|Fcm::CLI::Option>
  357. =head1 COPYRIGHT
  358. E<169> Crown copyright Met Office. All rights reserved.
  359. =cut