App-Cme-1.040/0000755000175000017500000000000014552007501011401 5ustar domidomiApp-Cme-1.040/README.install.pod0000644000175000017500000000154114552007501014510 0ustar domidomi=head1 Installation =head2 Debian or Ubuntu L is provided as Debian package. Just type sudo apt-get install cme Or use your favorite installer =head2 Fedora or RedHat L is now packaged by RedHat. Type: sudo yum install perl-App-Cme =head2 Mac OSX L is provided as ppm package by L: =over =item * Install L =item * Update your $PATH variable to run ActiveState's perl =item * Run ppm to install L =back =head2 Windows You can also install L from L. See the instructions for Mac OSX for details. =head2 Other systems For other systems, you should install L from CPAN: cpanp install App::Cme App-Cme-1.040/META.json0000644000175000017500000000502714552007501013026 0ustar domidomi{ "abstract" : "Configuration data checker or editor based on Config::Model", "author" : [ "Dominique Dumont" ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 6.030, CPAN::Meta::Converter version 2.150010", "license" : [ "lgpl_2_1" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "App-Cme", "prereqs" : { "build" : { "requires" : { "Module::Build" : "0.34" } }, "configure" : { "requires" : { "Module::Build" : "0.34" } }, "runtime" : { "recommends" : { "Config::Model::TkUI" : "1.370" }, "requires" : { "App::Cmd::Setup" : "0", "Config::Model" : "2.148", "Config::Model::FuseUI" : "0", "Config::Model::Lister" : "0", "Config::Model::ObjTreeScanner" : "0", "Config::Model::SimpleUI" : "0", "Config::Model::TermUI" : "0", "Config::Model::Utils::GenClassPod" : "0", "Data::Dumper" : "0", "Encode" : "0", "File::HomeDir" : "0", "JSON" : "0", "Log::Log4perl" : "0", "Path::Tiny" : "0", "Pod::POM" : "0", "Pod::POM::View::Text" : "0", "Scalar::Util" : "0", "Tie::Hash" : "0", "YAML::PP" : "0", "perl" : "5.020" }, "suggests" : { "Config::Model::CursesUI" : "0" } }, "test" : { "requires" : { "App::Cmd::Tester" : "0", "Config::Model" : "2.148", "English" : "0", "File::Spec" : "0", "Term::ANSIColor" : "2.01", "Test::File::Contents" : "0", "Test::More" : "0", "Test::Perl::Critic" : "0", "Test::Pod" : "1.00" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "mailto" : "ddumont at cpan.org", "web" : "https://github.com/dod38fr/cme-perl/issues" }, "homepage" : "https://github.com/dod38fr/config-model/wiki", "repository" : { "type" : "git", "url" : "https://github.com/dod38fr/cme-perl.git", "web" : "http://github.com/dod38fr/cme-perl" } }, "version" : "1.040", "x_generated_by_perl" : "v5.38.2", "x_serialization_backend" : "JSON::XS version 4.03", "x_spdx_expression" : "LGPL-2.1" } App-Cme-1.040/weaver.ini0000644000175000017500000000022014552007501013365 0ustar domidomi[@Default] [-Transformer] transformer = List [Support] perldoc = 0 bugs = metadata websites = search,ratings,kwalitee,testers,testmatrix,deps App-Cme-1.040/SIGNATURE0000644000175000017500000001061414552007501012667 0ustar domidomiThis file contains message digests of all files listed in MANIFEST, signed via the Module::Signature module, version 0.88. To verify the content in this distribution, first make sure you have Module::Signature installed, then type: % cpansign -v It will check each file's integrity, as well as the signature's validity. If "==> Signature verified OK! <==" is not displayed, the distribution may already have been compromised, and you should not run its Makefile.PL or Build.PL. -----BEGIN PGP SIGNED MESSAGE----- Hash: RIPEMD160 SHA256 1f0b05ffb40439c73fc5a259daaf144efc587858db391f51904795550d7aaae3 Build.PL SHA256 41518a40e785fd3fd40fb8726a2477eca7710849f982698ddadf729e931edd90 CONTRIBUTING.md SHA256 75ada5b35afc7b67950f693819f87562d0a8926ed90e08a0bc288b3812ad485a Changes SHA256 c6cf71f9f80f821c24aff50d5a237252fd1d141076a221b62f9dfb1e1603bf86 LICENSE SHA256 b288391c7b890c805c47806cb3f94694d2cb5839578991ebf908b2919bf338f7 MANIFEST SHA256 d68df94568cdc7d59e14123f79e33d1818d8d5441a2afe9cbe1143c9cd23deae MANIFEST.SKIP SHA256 ae7acd931ace10ffc28c5f8d3cd83c1d3b9679e40a862daa17003743d20329a8 META.json SHA256 f648af664b321877cee23566aeeb2f6613f9b1fa2ea7d8c603340e7d759f96cd META.yml SHA256 623f926346f339f2cb3d1571b4c40eca538eb86316c78363ca736704deb1b113 README.install.pod SHA256 085d69af567770eb8edd4ee329d7611418c86d84bd41f0d2a705a8d2f33167e7 README.pod SHA256 f5e2da85a463bd84a227fe884649408c7191963e92360b7015cfcf78e7431f70 bin/cme SHA256 0f67a996b4427c9d9984c085ac93d88d0e1717a6c74382f95b83b17e7520ee70 build-from-git.md SHA256 e8f96b7754ae1e2837e5643a74889ae00c95bd75b2c0483bd19092a3671a227a contrib/bash_completion.cme SHA256 ec4c522192d44a1bd0ef8a1c084dc700d2c189f55be9e096823202bccf3ee37a lib/App/Cme.pm SHA256 af32f2475331e1ef2e1d9a5f893c065914f8a845aa176259fd4faa556bb8501a lib/App/Cme/Command/check.pm SHA256 ec5cb34536cc2fe106d7b6026192475bc1d1fdfe736f9952b09481731ba7963c lib/App/Cme/Command/dump.pm SHA256 353a0bcd3b681fab83efa78cca712827d3f10f2f34d93c70c20043fafe99738c lib/App/Cme/Command/edit.pm SHA256 0625858548e53835842940420e260023073896bad45d5d196085ad23852180b4 lib/App/Cme/Command/fix.pm SHA256 e7162ae1854a3fe18fe1976875316c19617fcd22cb650a03e7d562e7183c32dc lib/App/Cme/Command/fusefs.pm SHA256 e8c218539d5444adc83a24f4fd6db734f791418a6b704d23a89808401439f4f8 lib/App/Cme/Command/gen_class_pod.pm SHA256 3175b76256a12b210ab121d2bb48ca8da2b78e516e8207adb4c19d9a9ef2ad37 lib/App/Cme/Command/list.pm SHA256 d89804d92b845047a7dc851c2c55906c7c42085f6f75f6113624a632686b1f2c lib/App/Cme/Command/migrate.pm SHA256 05a8ca6dcb9ed40af530d2acb9ee1c32f38cef00cffdaf9f2c63c4eab72c3977 lib/App/Cme/Command/modify.pm SHA256 3c76c49ab0889aaf7417b93a427a346b05ef450e928ea8c70c5de7884d801cbc lib/App/Cme/Command/run.pm SHA256 192c9f05b2cf9a39b609a77453e22f1a6554408bde620ad5969196337bb4176d lib/App/Cme/Command/search.pm SHA256 87c6c9247e0220b2dd3325139d797723fb399e1e8356d213c4a55b1b9ea2dc22 lib/App/Cme/Command/shell.pm SHA256 43f3418a755cd6e0d45feea412335bd1d637c2505ff7c8c7b0176e00147d4a3d lib/App/Cme/Command/update.pm SHA256 5edff47aba261ea8ed81e45772562137e8e53698627c1846dc6ba3dc0b6a0b9d lib/App/Cme/Common.pm SHA256 643d398845a8a29568940093f99b95cfebb6ea159a5b08f2f3efa4c995ec9bb9 t/cme-command.t SHA256 325afe4d3ac4dcf99b3d4bcfa7afe8d0b880412c53c0e161c6c577e4c30e2a2d t/perl-critic.t SHA256 06a7bedd3e79ac8a4585ce2197d9e673099cd363a035ccbc11d20f39a5a5d198 t/perlcriticrc SHA256 85056ca339b84a901563baa532e2e27c62b0807587988535a27e366783632f39 t/pod.t SHA256 833b1f1c8d533af934237ffc614f9d32dd25b947005fc959fcc88b860ee4ce7d t/run-internals.t SHA256 dc2e6b91767be659e12635d5f3a07055c69d4f57431492be23fc06935414ba6f weaver.ini -----BEGIN PGP SIGNATURE----- iQIzBAEBAwAdFiEEn3I5/LZk8Qsz6dwDwx9P2UmrK2wFAmWoD0EACgkQwx9P2Umr K2xcmA//QyvqEbPzBWBaMn5OpK60sjw2z87OWoGwUgf9NdtqgbTzHCqVndztiI3x /mrdc1WSzRGpp3Uj4/IqEVaT87zQAXySKfxNpAaZh5ZLNxpT7v3Jz8yFScyS/FYV 2ZXEakEBd+CZ5VWVi12t+zMu19F3S3ECRbXqlQs2ShyUVE3LR3j3hdPcvTXWdOGJ i0icQBTykt/IDqGiYrqySNDwLoV/qODZs6VtrjMDvbOgfbXyJQeTA9E2RYVNJTG0 D0vs7WI4xlHqzuD9esljNqFCmc7zixrCmmz6G2tr5BwcmaK/ot0y8ppKImkhs8wv LLQ7PExjbI45MozXvjIDtZOQWOb2nYy3r9l0yt0JY6DsU6RYKFIjQX9xsXU6CbuX TvF8n5FzZj66GZcUHgPTtuuOUfVv8JIWzA2r+cJF5pyv3j3rYPWhu0twLLqOltaz K9l7BnbeO0bvqnDcUEx+GvgJjqnwdO8zd24XO2kQO1GONCMD22WVTuBUVtOEUFF0 Get4FyDlzbcInlAgq2v0wQJrH/PWAuVFFYiKiVeyUdiQ8lAQZmG9zvFre8j0zZt2 o59p9zuLKfgZTXMl9jso5JLqn12uabJn1qQNOH2zWHqd/yUjQbzGgLUddtA4ts1R SwmHhV+BLMZkDe93wa83pAunQNzwITk3nKQvNwdqatV7VekDVDI= =LHIz -----END PGP SIGNATURE----- App-Cme-1.040/Changes0000644000175000017500000002516214552007501012702 0ustar domidomi1.040 2024-01-17 Bug fix: * fix deprecation warning 1.039 2023-12-09 New feature: * tkui: open write widget with "cme edit --open-item "" Bug fix: * cme run: improve heuristic to detect plain Perl script 1.038 2022-03-13 Bug fix: * run command: substitution of variable in commit message 1.037 2022-02-05 New feature: * allow code section in scripts * allow 'run' script in YAML or Perl format Misc changes: * remove "use XXX" from test script 1.036 2022-01-12 Bug fix: * fix test broken by output change in Config::Model 2.148 Misc changes: * tests requires Config::Model 2.148 1.035 2022-01-09 Bug fix: * fix postderef syntax with perl 5.20 * fix (run): --no-commit option * fix (run): do not try to commit when no changes are done * fix (test): broken by Config::Model 2.145 1.034 2021-10-30 New feature: * add use_backend_argument_as_config_file param to app files Misc changes: * require perl 5.20 * update copyright year * refactored following perlcritic advices 1.033 2021-09-19 Bug fix: * fix (fix command): display node name when needed * remove duplicate option definition * fix (run command): fix override of --commit option * fix force-load doc Dependency changes: * rm test dependency on Probe::Perl 1.032 2020-07-17 cme improvements: * cme warnings are now shown with log4perl in blue (the shown color depends on Log4Perl configuration) Doc improvements: * improve update command doc (Thanks Ross Vandegrift) * add contributor section in cme doc * run command: fix typos in synopsis comments 1.031 2020-01-12 Bug fix: * fix warning about deprecated -root parameter Misc: * suggest Config::Model::CursesUI instead of recommend * recommend Config::Model::TkUI >= 1.370 1.030 2019-09-11 Improve output of cme: * show more information when running "cme help" 1.029 2018-08-20 Bug fixes: * fix options diplayed by bash completion Smoke test fixes: * fix extra \n in output for perl < 5.18 1.028 2018-06-20 Documentation improvements: * add bugs section in cme doc * improve doc of modify command Improve output of cme: * check and modify commands are now silent when no problem is found. * run and modify commands show detailed script actions on configuration data in verbose mode * dump command: indicate -format choices in usage output * check command: show progress messages only in verbose mode. * fix command: show "running fix" message only in verbose mode * common: remove using xxx model message Bash completion fixes: * remove obsolete -backend option * fix bash completion of run command Other: * requires Config::Model 2.124 * run: allow untracked files when committing * cme: Simplify verbose option 1.027 2018-04-05 Improve cme run script: * add error message when application param is missing * leave capture parameters alone * add syntax for multi-line instructions * replace_var sub accepts several variabless * fix error message when run is called without argument Other: * Using cme option '-file' with value '-' is deprecated * update copyright year in dist.ini 1.026 2017-12-18 New experimental feature: * By default, Shellvar backend from Config::Model 2.116 keeps parameter order when writing back configuration data. This broke cme test that check that data is written with canonical order * add -canonical option to let data be written back according to model order (i.e. the previous behavior of shellvar backend) * Fix test broken by new ShellVar behavior (using -canonical option) * Depends on Config::Model 2.116 (for -canonical option) On-going deprecation of obscure multi backend feature * cme: remove obsolete -backend option (since only one backend can now be available, there's no need to an option to choose an alternative backend) 1.025 2017-12-14 Some new features for the rather new 'run' subcommand: * add -cat option option to show the script * -doc option also shows commit message New feature for the older 'dump' subcommand * -format accepts yaml or yml * -format value is now case insensitive * accept -format cds (alias to cml) Misc: * improve doc of modify command 1.024 2017-10-22 Some new features for the rather new 'run' subcommand: * add --no-commit option (Debian #877986) * add --commit option * can now specify default value for script args Other bug fixes: * run: remove warning about Log4Perl initialisation * run: fix option description * cme: update Log4Perl init in doc 1.023 2017-09-10 Bug fixes: * add missing backup option to read/write commands (like cme edit, fix, modify ...) * die if both require_config_file and require_backend_argument are set in app file (in Config/Model/[system|user|application].d) 1.022 2017-06-21 Bug fixes for smoke test failures: * test failure exit code to be != 0 * work-around test issue with perl < 5,18 1.021 2017-06-18 Bug fixes: * try to smoke test failures: convert cme test to use App::Cmd::Tester * remove deprecated arg '~~' from doc 1.020 2017-06-05 Improvements for all commands : * allow backend_argument (used by systemd) * unknown options trigger a warning Bug fixes: * all: fix bash completion of -file option * cme run: fix bash_completion of -doc option * cme allow non_upstream_default mode * all: remove -dev option which raises security issues. Use 'perl -Ilib -S cme' for the same effect 1.019 2017-04-30 This release brings some improvements: * run: allow to use command args in var: lines * cme: add '-verbose [ info | debug | trace ]' option to get debug logs Other bug fixes: * do not replace hash variable in run script 1.018 2017-04-07 This release improve 'cme run' command to make it more useful: * add -list option * can compute script variables (var: section) * can use environment variables * add possibility for scritps to provide their own doc displayed with 'cme run xxx -doc' * die when if a script variable is not defined * look for system scripts in /usr/share/ * add bash completion for cme run command Other changes: * save option can now be used with all subcommand 1.017 2017-03-05 This release bring a new cme sub-command to let you create small configuration scripts: cme run Misc: * update © years 1.016 2016-12-12 Bug fix: * check command: propagate -force option to skip load check * dump command must always be in quiet mode 1.015 2016-10-14 Bug fix: * cme: support utf8 in command args (Debian #839593) 1.014 2016-09-24 Improvements: * run deep_check when running commands check, edit, modify, shell (requires Config::Model 2.089) * improved error msg for unknown app (Closes Debian #836794) Bug fix: * cme: fix -strack-trace option 1.013 2016-07-10 Usability improvements: * clarify doc of -strict option (check cmd) * fix typo in pod doc (tx Thomas Schmitt) * suggest 'cme fix' when 'cme check' finds warnings * add CONTRIBUTE.md 1.012 2016-05-29 Bug fix: * edit command degrades gracefully when recommended packages are not isntalled * shell command degrades gracefully without Term::ReadLine 1.011 2016-04-21 New functionality: * dump command can dump any config file(s) in YAML, JSON or Perl format. 1.010 2016-01-30 New functionality: * Can read configuration directory from application file, e.g. user.d/ssh. This will help reuse Model between applications (e.g. systemd and systemd --user). This requires Config::Model 2.077 Bug fix: * cme list: fix -dev option option (Debian #813188) 1.009 2016-01-02 Bug fix release: * remove warning about missing config file. It's better to let the read/write backend handle bogus config file * update command: improved messages shown to user * list command: now work with -dev option 1.008 2015-11-14 Bug fix release: * fix -save option with modify command * fix -try-app-as-model option 1.007 2015-10-25 Usability improvements: * cme: added -file option to replace '~~' argument * bash_completion: added update sub command Doc fixes: * cme: fixed synopsis * cme: added update doc 1.006 2015-07-19 Doc fix release: * cme edit doc: don't abuse L<> tag which are change in "the xxx manpage" * cme list: improve help shown to user * cme help: transform pod to text to avoid showing pod markup * cme fix: corrected small mistakes in doc * cme check: added another example in pod doc 1.005 2015-05-25 * all: fixed confusing unwarranted warning message (about ~~ argument) 1.004 2015-05-25 Mostly a bug fix release. Please use now github to report issues on cme ( https://github.com/dod38fr/cme-perl/issues ) * metadata: * switched bugtracker to github's * fixed repo and website urls (Tx xtaran) * all: add a warning if conf file is not found (may mean a missing ~~ argument). (I'd welcome ideas on how to replace this iffy ~~ argument) * dump command: + added possibility to select a node to dump * fixed -dumptype which is not mandatory * test can run with local cme or system cme to fix debian continuous integrations tests 1.003 2015-04-26 Bug fix release: * Common: pass cme messages through on_message_cb * update: call C::M::Instance->update (require Config::Model 2.068) * remove debug call to YYY 1.002 2015-01-10 * gen-class-pod: * fix doc and missing command arguments * update: + added -edit option to run editor after an update * fix typo in pod doc * dist.ini: updated © to 2015 1.001 2014-11-29 * require Config::Model 2.063 (to avoid bash_completion clash) * improved messages printed by update command * added 'gen-class-pod' alias for gen_class_pod * bash_completion: + added help version commands update in hard-coded list of commands * fixed syntax error 0.001 2014-11-25 First release of App::Cme. These are the changes done to cme compared to the old cme shipped with Config::Model 2.061: * Cme has been re-written with App::Cmd - old mechanism for cme extension is removed. Extensions support is provided by App::Cmd + added gen_class_pod and update commands + added -quiet option to suppress progress messages * fix mistached options wrt available commands in bash_completion * added -root-dir option (used for tests) App-Cme-1.040/CONTRIBUTING.md0000644000175000017500000000443714552007501013642 0ustar domidomi# How to contribute # ## Ask questions ## Yes, asking a question is a form of contribution that helps the author to improve documentation. Feel free to ask questions by sending a mail to [the author](mailto:ddumont@cpan.org) ## Log a bug ## Please report issue on[cme issue tracker](https://github.com/dod38fr/cme-perl/issues). ## Source code structure ## The main parts of this modules are: * `bin/cme`: mostly cme command documentation * `contrib/bash_completion.cme`: the file that enable user to type 'cme[TAB]' and get the list of available sub-commands. See bash man page for more details on bash completion * `lib/App/Cme/Command/**.pm`: implementation of cme sub-commands * `t`: test files. Run the tests with `prove -l t` ## Edit source code from github ## If you have a github account, you can clone a repo and prepare a pull-request. You can: * run `git clone https://github.com/dod38fr/cme-perl` * edit files * run `prove -l t` to run non-regression tests There's no need to worry about `dzil`, `Dist::Zilla` or `dist.ini` files. These are useful to prepare a new release, but not to fix bugs. ## Edit source code from Debian source package ## You can also prepare a patch using Debian source package: For instance: * download and unpack `apt-get source cme` * jump in `cd cme-1.xxx` * useful to create a patch later: `git init` * commit all files: `git add -A ; git commit -m"committed all"` * edit files * run `prove -l t` to run non-regression tests * run `git diff` and send the output to the [author](mailto:ddumont@cpan.org) ## Edit source code from Debian source package or CPAN tarball ## Non Debian users can also prepare a patch using CPAN tarball: * Download tar file from http://search.cpan.org * unpack tar file with something like `tar axvf App-Cme-1.xxx.tar.gz` * jump in `cd App-Cme-1.xxx` * useful to create a patch later: `git init` * commit all files: `git add -A ; git commit -m"committed all"` * edit files * run `prove -l t` to run non-regression tests * run `git diff` and send the output to the [author](mailto:ddumont@cpan.org) ## Provide feedback ## Feedback is important. Please take a moment to rate, comment or add stars to this project: * [cme github](https://github.com/dod38fr/cme-perl) or [cme cpan ratings](http://cpanratings.perl.org/rate/?distribution=App-Cme) App-Cme-1.040/MANIFEST.SKIP0000644000175000017500000000016514552007501013301 0ustar domidomi^debian/ ~$ \.ptkdb$ \.old$ dist.ini libconfig _build \.orig$ ^MYMETA.yml$ blib wr_root \.rej$ README.build-from-git App-Cme-1.040/README.pod0000644000175000017500000000457014552007501013050 0ustar domidomi=begin html =end html =head1 cme - Check or edit configuration data L provides a command to check or edit configuration data with L. L and L are quite modular: the configuration data that you can edit depend on the other C distributions installed on your system. For instance, to configure L or L, you need to install L. Then you can check your ssh configuration with this command: $ cme check ssh and you can modify it with: $ cme edit ssh The L contains a L L provides several commands. The most important are : =over =item check To check the content of the configuration file of an application. =item fix To fix the warnings of the configuration file. =item edit To launch cme interactive editor. This editor contains documentation and sanity checks to help user configure correctly their application. =back L user interface can be: =over =item * Graphical if L is installed. =item * a shell-like interface (plain or based on L). =item * based on curses if L is installed. =back By default, C will try to launch a GUI. =head2 Installation See L. Perl developers can also L =head2 What does "cme" means ? Nothing fancy: "Config Model Editor". The idea was to L. =head2 More information See =over =item * L man page =item * L (i.e. the wiki tab above) =item * L =item * The list of available models, interfaces and known configuration syntaxes: https://github.com/dod38fr/config-model/wiki/Available-models-and-backends =back App-Cme-1.040/bin/0000755000175000017500000000000014552007501012151 5ustar domidomiApp-Cme-1.040/bin/cme0000755000175000017500000002642414552007501012653 0ustar domidomi#!/usr/bin/env perl # # This file is part of App-Cme # # This software is Copyright (c) 2014-2022 by Dominique Dumont . # # This is free software, licensed under: # # The GNU Lesser General Public License, Version 2.1, February 1999 # # PODNAME: cme # ABSTRACT: Check or edit configuration data with Config::Model # see perlunicook use utf8; # so literals and identifiers can be in UTF-8 use v5.12; # or later to get "unicode_strings" feature use strict; # quote strings, declare variables use warnings; # on by default use warnings qw(FATAL utf8); # fatalize encoding glitches use open qw(:std :utf8); # undeclared streams in UTF-8 use charnames qw(:full :short); # unneeded in v5.16 use App::Cme; App::Cme->run; __END__ =pod =encoding UTF-8 =head1 NAME cme - Check or edit configuration data with Config::Model =head1 VERSION version 1.040 =head1 SYNOPSIS # general synopsis cme [ global_options ] command application [ options ] [ file ] [ modification_instructions ] # edit dpkg config with GUI (and Config::Model::Dpkg) cme edit dpkg # read data from arbitrary file (for model read from alternate file) cme check dpkg-copyright -file path/to/file # edit /etc/sshd_config (with Config::Model::OpenSsh) sudo cme edit sshd # edit ~/.ssh/config (with Config::Model::OpenSsh) cme edit ssh # just check the validity of a file. Both commands are equivalent cme check multistrap file.conf cme check multistrap -file file.conf # check dpkg files, update deprecated parameters and save cme migrate dpkg # like migrate, but also apply all suggested fixes cme fix dpkg # modify configuration with command line cme modify dpkg source 'format="(3.0) quilt"' # likewise with an application that accepts file override cme modify dpkg-copyright 'Comment="Modified with cme"' # edit a file (file name specification is mandatory here) cme edit multistrap my.conf # map conf data to a fuse file system cme fusefs multistrap my.conf -d fuse_dir # likewise for dpkg data cme fusefs dpkg -d fuse_dir # list all available applications (depends on your installation) cme list =head1 DESCRIPTION Depending on the command described below, C program will use Config::Model configuration descriptions to check or modify or fix configuration files. The 3rd parameter specify the application you want to work on. Most of the time, the relevant configuration file(s) will be found by cme. This is the most simple case. For instance: sudo cme check popcon Some application like C have no constraint on the configuration file name and will require you to specify your configuration file name: cme check multistrap raspbian.conf or cme check multistrap -file raspbian.conf =head1 Configuration file specification The configuration of an application can take different forms. Either several files (like debian packages), a single file with a predefined file (popcon), or a single file with an arbitrary file name (multistrap). When needed the configuration file name is specified as the 3rd command argument, i.e. C. This applies if the application requires a configuration file name (like multistrap), or if the application allows configuration file override. =head1 Main commands This section describes the main commands shipped with cme. Other Config::Model extensions can bring more command. Run C to get the list of available commands on your system. =head2 list Show a list all applications where a model is available. This list depends on installed Config::Model modules. =head2 edit Edit a configuration. By default, a Tk GUI will be opened If L is installed. See L. =head2 shell Edit the configuration with a shell like interface. See L. =head2 check Checks the content of the configuration file of an application. See L. =head2 migrate Update deprecated parameters (old value are saved to new parameters) and save the new configuration. See L. =head2 fix Migrate data and fix warnings. See L. =head2 modify Modify a configuration file with the values passed on the command line. See L. =head2 update Update the content of the configuration file from external data. Currently, only dpkg-copyright model support update sub command. See L. =head2 search Search configuration data for a specific string. See L. =head2 fusefs Map the configuration file content to a FUSE virtual file system on a directory specified with option C<-fuse-dir>. Modifications done in the fuse file system are saved to the configuration file when the C is run. =head1 Global options The following options are available for all commands: =over =item -create Perform the operation even if the configuration file is missing. This may be used to create a minimal configuration file. This option is disabled by default as a missing configuration file often indicates an error during the installation of the application. =item -file For model that support it, specify an alternate file to read and write the configuration. You can use this option for model that require the target file to be specified (e.g. multitrap model), but file can in this case be also specified with the 4th command argument. E.g. these 2 commands have the same effect: cme check multistrap foo.conf cme check multistrap -file foo.conf =item -force-load Load file even if error are found in data. Bad data are discarded =item -canonical Write config data back using model order. By default, write items back using the order found in the configuration file. This feature is experimental and not supported by all backends. =item -backup Create a backup of configuration files before saving. By default, C will be appended to the backup file. I.e. C will be backed up as C. You can specify an alternate suffix. For instance C<-backup dpkg-old>. =item -save Force a save even if no change was done. Useful to reformat the configuration file. =item -strict When set, cme will exit 1 if warnings are found during check (of left after fix) =item -verbose Show more information about what's going on. =item -quiet Suppress all output except error messages. =back =head1 Advanced options =over =item -model-dir Specify an alternate directory to find model files. Mostly useful for tests. =item -root-dir Specify a pseudo root directory to read and write the configuration files. (Actual default directory and file names depends on the model (See C<-model> option). For instance, if you specify C<~/mytest>, the C files will be written in C<~/mytest/etc/ssh/> directory. =item -stack-trace Provides a full stack trace when exiting on error. =item -try-app-as-model When set, try to load a model using directly the application name specified as 3rd parameter on the command line. Experimental. =back =head1 Embedding cme You can use cme from another program by using C<-ui simple> option. This way you will be able to send command on the standard input of C and get the results from the standard output. =head1 Logging All Config::Model logging is now based on L. Logging can be configured in the following files: =over =item * ~/.log4config-model =item * /etc/log4config-model.conf =back A sample of a C<.log4config-model> is provided in contrib directory in C distribution of on L Without these files, the following Log4perl config is used: log4perl.rootLogger=WARN, Screen log4perl.logger.Model.Legacy = INFO, SimpleScreen log4perl.additivity.Model.Legacy = 0 log4perl.appender.Screen = Log::Log4perl::Appender::Screen log4perl.appender.Screen.stderr = 0 log4perl.appender.Screen.layout = Log::Log4perl::Layout::PatternLayout log4perl.appender.Screen.layout.ConversionPattern = %M %m (line %L)%n log4perl.appender.SimpleScreen = Log::Log4perl::Appender::Screen log4perl.appender.SimpleScreen.stderr = 0 log4perl.appender.SimpleScreen.layout = Log::Log4perl::Layout::PatternLayout log4perl.appender.SimpleScreen.layout.ConversionPattern = %p: %m%n log4perl.oneMessagePerAppender = 1 Log4perl uses the following categories: =over =item Anything =item Anything::Change Trace change notification through configuration tree and instance. =item Backend =item Backend::Debian::Dpkg =item Backend::Debian::Dpkg::Control =item Backend::Debian::Dpkg::Copyright =item Backend::Fstab =item Backend::IniFile =item Backend::PlainFile =item Backend::ShellVar =item Backend::Yaml =item FuseUI =item Instance =item Loader =item Model::Searcher =item Tree::Element::CheckList =item Tree::Element::Id =item Tree::Element::Id::Hash =item Tree::Element::Id::List =item Tree::Element::Value =item Tree::Element::Value::Dependency =item Tree::Node =item Tree::Node::Warped =item ValueComputer =item Warper =item Iterator =item Model =back More categories will come. =head1 EXIT CODE cme exits 0 when no errors are found. Exit 1 otherwise. =head1 BUGS =head2 Files may be re-ordered C imposes a specific ordering of the parameters of a configuration file. This ordering is derived from the documentation of the configuration, like L. C writes back files using this ordering. Thus, the diff between the original configuration files and the new version of the file may be more important than expected when C is used the first time. =head2 Comments may be dropped Comments are not supported in some applidations (like the one that use YAML in configuration files). Comments are dropped when using C to edit or modify such files. For more details, see L page. =head2 Configuration models can lag behind the target application If a configuration model is not up-to-date, you will get errors complaining about unknown parameters. In such a case, please file a bug on L or fix the model and send a pull request. You can see this L to learn how to fix a model. =head1 FOR MORE INFORMATION For more information, please check: =over =item * config-model wiki: L =item * Blogs about this project: L =back =head1 CONTRIBUTORS In alphabetical order: Ross Vandegrift =head1 FEEDBACKS Feedback from users are highly desired. If you find this module useful, please share your use cases, success stories with the author. =head1 SEE ALSO L, L, L, L, L, L, L =head1 AUTHOR Dominique Dumont =head1 COPYRIGHT AND LICENSE This software is Copyright (c) 2014-2022 by Dominique Dumont . This is free software, licensed under: The GNU Lesser General Public License, Version 2.1, February 1999 =cut App-Cme-1.040/Build.PL0000644000175000017500000000441514552007501012701 0ustar domidomi# # This file is part of App-Cme # # This software is Copyright (c) 2014-2022 by Dominique Dumont . # # This is free software, licensed under: # # The GNU Lesser General Public License, Version 2.1, February 1999 # # This file was automatically generated by Dist::Zilla::Plugin::ModuleBuild v6.030. use strict; use warnings; use Module::Build 0.34; my %module_build_args = ( "build_requires" => { "Module::Build" => "0.34" }, "configure_requires" => { "Module::Build" => "0.34" }, "dist_abstract" => "Configuration data checker or editor based on Config::Model", "dist_author" => [ "Dominique Dumont" ], "dist_name" => "App-Cme", "dist_version" => "1.040", "license" => "lgpl", "module_name" => "App::Cme", "recommends" => { "Config::Model::TkUI" => "1.370" }, "recursive_test_files" => 1, "requires" => { "App::Cmd::Setup" => 0, "Config::Model" => "2.148", "Config::Model::FuseUI" => 0, "Config::Model::Lister" => 0, "Config::Model::ObjTreeScanner" => 0, "Config::Model::SimpleUI" => 0, "Config::Model::TermUI" => 0, "Config::Model::Utils::GenClassPod" => 0, "Data::Dumper" => 0, "Encode" => 0, "File::HomeDir" => 0, "JSON" => 0, "Log::Log4perl" => 0, "Path::Tiny" => 0, "Pod::POM" => 0, "Pod::POM::View::Text" => 0, "Scalar::Util" => 0, "Tie::Hash" => 0, "YAML::PP" => 0, "perl" => "5.020" }, "script_files" => [ "bin/cme" ], "test_requires" => { "App::Cmd::Tester" => 0, "Config::Model" => "2.148", "English" => 0, "File::Spec" => 0, "Term::ANSIColor" => "2.01", "Test::File::Contents" => 0, "Test::More" => 0, "Test::Perl::Critic" => 0, "Test::Pod" => "1.00" } ); my %fallback_build_requires = ( "App::Cmd::Tester" => 0, "Config::Model" => "2.148", "English" => 0, "File::Spec" => 0, "Module::Build" => "0.34", "Term::ANSIColor" => "2.01", "Test::File::Contents" => 0, "Test::More" => 0, "Test::Perl::Critic" => 0, "Test::Pod" => "1.00" ); unless ( eval { Module::Build->VERSION(0.4004) } ) { delete $module_build_args{test_requires}; $module_build_args{build_requires} = \%fallback_build_requires; } my $build = Module::Build->new(%module_build_args); $build->create_build_script; App-Cme-1.040/lib/0000755000175000017500000000000014552007501012147 5ustar domidomiApp-Cme-1.040/lib/App/0000755000175000017500000000000014552007501012667 5ustar domidomiApp-Cme-1.040/lib/App/Cme/0000755000175000017500000000000014552007501013373 5ustar domidomiApp-Cme-1.040/lib/App/Cme/Command/0000755000175000017500000000000014552007501014751 5ustar domidomiApp-Cme-1.040/lib/App/Cme/Command/gen_class_pod.pm0000644000175000017500000000327014552007501020111 0ustar domidomi# # This file is part of App-Cme # # This software is Copyright (c) 2014-2022 by Dominique Dumont . # # This is free software, licensed under: # # The GNU Lesser General Public License, Version 2.1, February 1999 # # ABSTRACT: Generates pod doc from model files package App::Cme::Command::gen_class_pod ; $App::Cme::Command::gen_class_pod::VERSION = '1.040'; use strict; use warnings; use 5.10.1; use App::Cme -command ; use Config::Model::Utils::GenClassPod; sub command_names { my $self = shift ; return ( 'gen-class-pod' , $self->SUPER::command_names ); } sub description { return << "EOD" Generate pod documentation from configuration models found in ./lib directory EOD } sub execute { my ($self, $opt, $args) = @_; gen_class_pod(@$args); return; } 1; __END__ =pod =encoding UTF-8 =head1 NAME App::Cme::Command::gen_class_pod - Generates pod doc from model files =head1 VERSION version 1.040 =head1 SYNOPSIS cme gen-class-pod [ Foo ... ] =head1 DESCRIPTION This command scans C<./lib/Config/Model/models/*.d> and generate pod documentation for each file found there using L You can also pass one or more class names. C will write the documentation for each passed class and all other classes used by the passed classes. =head1 SEE ALSO L, L =head1 AUTHOR Dominique Dumont =head1 COPYRIGHT AND LICENSE This software is Copyright (c) 2014-2022 by Dominique Dumont . This is free software, licensed under: The GNU Lesser General Public License, Version 2.1, February 1999 =cut App-Cme-1.040/lib/App/Cme/Command/shell.pm0000644000175000017500000000472414552007501016425 0ustar domidomi# # This file is part of App-Cme # # This software is Copyright (c) 2014-2022 by Dominique Dumont . # # This is free software, licensed under: # # The GNU Lesser General Public License, Version 2.1, February 1999 # # ABSTRACT: Edit the configuration of an application with a shell package App::Cme::Command::shell ; $App::Cme::Command::shell::VERSION = '1.040'; use strict; use warnings; use 5.10.1; use App::Cme -command ; use base qw/App::Cme::Common/; sub validate_args { my ($self, $opt, $args) = @_; $self->check_unknown_args($args); $self->process_args($opt,$args); return; } sub opt_spec { my ( $class, $app ) = @_; return ( [ "open-item=s" => "open a specific item of the configuration" ], [ "backup:s" => "Create a backup of configuration files before saving." ], [ "bare!" => "run bare terminal UI"], $class->cme_global_options, ); } sub usage_desc { my ($self) = @_; my $desc = $self->SUPER::usage_desc; # "%c COMMAND %o" return "$desc [application] [file ]"; } sub description { my ($self) = @_; return $self->get_documentation; } sub execute { my ($self, $opt, $args) = @_; my ($model, $inst, $root) = $self->init_cme($opt,$args); $root->deep_check; if ($opt->{bare}) { require Config::Model::SimpleUI; $self->run_shell_ui('Config::Model::SimpleUI', $inst) ; } else { require Config::Model::TermUI; $self->run_shell_ui('Config::Model::TermUI', $inst) ; } return; } 1; __END__ =pod =encoding UTF-8 =head1 NAME App::Cme::Command::shell - Edit the configuration of an application with a shell =head1 VERSION version 1.040 =head1 SYNOPSIS # simple shell like interface cme shell dpkg-copyright =head1 DESCRIPTION Edit the configuration with a shell like interface. See L for details. This is a shortcut for C. See L. =head1 Common options See L. =head1 options =over =item -open-item Open a specific item of the configuration when opening the editor =item -bare Use Term UI without auto-completion or font enhancements. =back =head1 SEE ALSO L =head1 AUTHOR Dominique Dumont =head1 COPYRIGHT AND LICENSE This software is Copyright (c) 2014-2022 by Dominique Dumont . This is free software, licensed under: The GNU Lesser General Public License, Version 2.1, February 1999 =cut App-Cme-1.040/lib/App/Cme/Command/update.pm0000644000175000017500000000635414552007501016601 0ustar domidomi# # This file is part of App-Cme # # This software is Copyright (c) 2014-2022 by Dominique Dumont . # # This is free software, licensed under: # # The GNU Lesser General Public License, Version 2.1, February 1999 # # ABSTRACT: Update the configuration of an application package App::Cme::Command::update ; $App::Cme::Command::update::VERSION = '1.040'; use strict; use warnings; use 5.10.1; use App::Cme -command ; use base qw/App::Cme::Common/; use Config::Model::ObjTreeScanner; use Config::Model; sub validate_args { my ($self, $opt, $args) = @_; $self->check_unknown_args($args); $self->process_args($opt,$args); return; } sub opt_spec { my ( $class, $app ) = @_; return ( [ "edit!" => "Run editor after update is done" ], [ "backup:s" => "Create a backup of configuration files before saving." ], $class->cme_global_options, ); } sub usage_desc { my ($self) = @_; my $desc = $self->SUPER::usage_desc; # "%c COMMAND %o" return "$desc [application] [file ]"; } sub description { my ($self) = @_; return $self->get_documentation; } sub execute { my ($self, $opt, $args) = @_; my ( $inst) = $self->instance($opt,$args); say "Updating data..." unless $opt->{quiet}; my @msgs = $inst->update(quiet => $opt->{quiet}); if (@msgs and not $opt->{quiet}) { say "Update done"; } elsif (not $opt->{quiet}) { say "Command done, but ".$opt->{_application} . " model has no provision for update"; } if ($opt->{edit}) { say join("\n", grep {defined $_} @msgs ); $self->run_tk_ui ( $inst, $opt); } else { $self->save($inst,$opt) ; say join("\n", grep {defined $_} @msgs ); } return; } 1; __END__ =pod =encoding UTF-8 =head1 NAME App::Cme::Command::update - Update the configuration of an application =head1 VERSION version 1.040 =head1 SYNOPSIS cme update # example: cme update dpkg-copyright =head1 DESCRIPTION Update a configuration file. The update is done scanning external resource. For instance, C command can be used to update a specific Debian package file (C). This is done by scanning the headers of source files. Currently, only dpkg-copyright application currently supports updates. The configuration data (i.e. the content of C in this example) is mapped to a tree structure inside L. You can: =over 4 =item * view this structure in YAML format by running C =item * view this structure in Config::Model's format (aka C) by running C. This format is documented in L. =item * get a graphical view with C. =back =head1 Common options See L. =head1 options =over =item -open-item Open a specific item of the configuration when opening the editor =back =head1 SEE ALSO L =head1 AUTHOR Dominique Dumont =head1 COPYRIGHT AND LICENSE This software is Copyright (c) 2014-2022 by Dominique Dumont . This is free software, licensed under: The GNU Lesser General Public License, Version 2.1, February 1999 =cut App-Cme-1.040/lib/App/Cme/Command/modify.pm0000644000175000017500000000675514552007501016613 0ustar domidomi# # This file is part of App-Cme # # This software is Copyright (c) 2014-2022 by Dominique Dumont . # # This is free software, licensed under: # # The GNU Lesser General Public License, Version 2.1, February 1999 # # ABSTRACT: Modify the configuration of an application package App::Cme::Command::modify ; $App::Cme::Command::modify::VERSION = '1.040'; use strict; use warnings; use 5.10.1; use App::Cme -command ; use base qw/App::Cme::Common/; use Config::Model::ObjTreeScanner; use Config::Model qw/initialize_log4perl/; sub validate_args { my ($self, $opt, $args) = @_; $self->check_unknown_args($args); $self->process_args($opt,$args); $self->usage_error("No modification instructions given on command line") unless @$args or $opt->{save}; return; } sub opt_spec { my ( $class, $app ) = @_; return ( [ "backup:s" => "Create a backup of configuration files before saving." ], $class->cme_global_options, ); } sub usage_desc { my ($self) = @_; my $desc = $self->SUPER::usage_desc; # "%c COMMAND %o" return "$desc [application] [file ] instructions"; } sub description { my ($self) = @_; return $self->get_documentation; } sub execute { my ($self, $opt, $args) = @_; $opt->{_verbose} = 'Loader' if $opt->{verbose}; my ($model, $inst, $root) = $self->init_cme($opt,$args); # needed to create write_back subs $root->dump_tree() if $opt->{save} and not @$args; $root->load("@$args"); $root->deep_check; # consistency check $self->save($inst,$opt) ; return; } 1; __END__ =pod =encoding UTF-8 =head1 NAME App::Cme::Command::modify - Modify the configuration of an application =head1 VERSION version 1.040 =head1 SYNOPSIS # modify configuration with command line cme modify dpkg source 'format="(3.0) quilt"' =head1 DESCRIPTION Modify a configuration file with the values passed on the command line. These command must follow the syntax defined in L (which is similar to the output of L command) Example: cme modify dpkg 'source format="(3.0) quilt"' cme modify multistrap my_mstrap.conf 'sections:base source="http://ftp.fr.debian.org"' Some application like dpkg-copyright allows you to override the configuration file name. You must then use C<-file> option: cme modify dpkg-copyright -file ubuntu/copyright 'Comment="Silly example"' Finding the right instructions to perform a modification may be difficult when starting from scratch. To get started, you can run C command to get the content of your configuration in the syntax accepted by C: $ cme dump ssh -format cml Host:"*" - Host:"alioth.debian.org" User=dod - Host:"*.debian.org" IdentityFile:="~/.ssh/id_debian" User=dod - Then you can use this output to create instruction for a modification: $ cme modify ssh 'Host:"*" User=dod' Changes applied to ssh configuration: - Host:"*" User has new value: 'dod' =head1 Common options See L. =head1 options =over =item -savek Force a save even if no change was done. Useful to reformat the configuration file. =item -verbose Show effect of the modify instructions. =back =head1 SEE ALSO L =head1 AUTHOR Dominique Dumont =head1 COPYRIGHT AND LICENSE This software is Copyright (c) 2014-2022 by Dominique Dumont . This is free software, licensed under: The GNU Lesser General Public License, Version 2.1, February 1999 =cut App-Cme-1.040/lib/App/Cme/Command/fix.pm0000644000175000017500000000616314552007501016103 0ustar domidomi# # This file is part of App-Cme # # This software is Copyright (c) 2014-2022 by Dominique Dumont . # # This is free software, licensed under: # # The GNU Lesser General Public License, Version 2.1, February 1999 # # ABSTRACT: Fix the configuration of an application package App::Cme::Command::fix ; $App::Cme::Command::fix::VERSION = '1.040'; use strict; use warnings; use 5.10.1; use App::Cme -command ; use base qw/App::Cme::Common/; use Config::Model::ObjTreeScanner; sub validate_args { my ($self, $opt, $args) = @_; $self->check_unknown_args($args); $self->process_args($opt,$args); return; } sub opt_spec { my ( $class, $app ) = @_; return ( [ "from=s@" => "fix only a subset of a configuration tree" ], [ "backup:s" => "Create a backup of configuration files before saving." ], [ "filter=s" => "pattern to select the element name to be fixed"], $class->cme_global_options, ); } sub usage_desc { my ($self) = @_; my $desc = $self->SUPER::usage_desc; # "%c COMMAND %o" return "$desc [application] [ file ]"; } sub description { my ($self) = @_; return $self->get_documentation; } sub execute { my ($self, $opt, $args) = @_; my ($model, $inst, $root) = $self->init_cme($opt,$args); my @fix_from = $opt->{from} ? @{$opt->{from}} : ('') ; foreach my $path (@fix_from) { my $node_to_fix = $inst->config_root->grab($path); my $msg = "cme: running fix on ".$inst->name." configuration"; $msg .= "from node ". $node_to_fix->name if $path; say $msg. "..." if $opt->{verbose}; $node_to_fix->apply_fixes($opt->{fix_filter}); } $self->save($inst,$opt) ; return; } 1; __END__ =pod =encoding UTF-8 =head1 NAME App::Cme::Command::fix - Fix the configuration of an application =head1 VERSION version 1.040 =head1 SYNOPSIS # fix dpkg (this example requires Config::Model::Dpkg) cme fix dpkg =head1 DESCRIPTION Checks the content of the configuration file of an application (and show warnings if needed), update deprecated parameters (old value are saved to new parameters) and fix warnings are fixed. The configuration is saved if anything was changed. If no changes are done, the file is not saved. =head1 Common options See L. =head1 options =over =item from Use option C<-from> to fix only a subset of a configuration tree. Example: cme fix dpkg -from 'control binary:foo Depends' This option can be repeated: cme fix dpkg -from 'control binary:foo Depends' -from 'control source Build-Depends' =item filter Filter the leaf according to a pattern. The pattern is applied to the element name to be fixed Example: cme fix dpkg -from control -filter Build # will fix all Build-Depends and Build-Depend-Indep or cme fix dpkg -filter Depend =back =head1 SEE ALSO L, L =head1 AUTHOR Dominique Dumont =head1 COPYRIGHT AND LICENSE This software is Copyright (c) 2014-2022 by Dominique Dumont . This is free software, licensed under: The GNU Lesser General Public License, Version 2.1, February 1999 =cut App-Cme-1.040/lib/App/Cme/Command/check.pm0000644000175000017500000000634514552007501016374 0ustar domidomi# # This file is part of App-Cme # # This software is Copyright (c) 2014-2022 by Dominique Dumont . # # This is free software, licensed under: # # The GNU Lesser General Public License, Version 2.1, February 1999 # # ABSTRACT: Check the configuration of an application package App::Cme::Command::check ; $App::Cme::Command::check::VERSION = '1.040'; use strict; use warnings; use 5.10.1; use App::Cme -command ; use base qw/App::Cme::Common/; use Config::Model::ObjTreeScanner; sub validate_args { my ($self, $opt, $args) = @_; $self->check_unknown_args($args); $self->process_args($opt,$args); return; } sub opt_spec { my ( $class, $app ) = @_; return ( [ "strict!" => "cme will exit 1 if warnings are found during check" ], $class->cme_global_options, ); } sub usage_desc { my ($self) = @_; my $desc = $self->SUPER::usage_desc; # "%c COMMAND %o" return "$desc [application] [ config_file ]"; } sub description { my ($self) = @_; return $self->get_documentation; } sub execute { my ($self, $opt, $args) = @_; my ($model, $inst, $root) = $self->init_cme($opt,$args); my $check = $opt->{force_load} ? 'no' : 'yes' ; say "Loading data..." if $opt->{verbose}; Config::Model::ObjTreeScanner->new( leaf_cb => sub { }, check => $check, )->scan_node( undef, $root ); say "Checking data.." if $opt->{verbose}; $root->dump_tree( mode => 'full' ); # light check (value per value) $root->deep_check; # consistency check say "Check done." if $opt->{verbose}; my $ouch = $inst->has_warning; if ( $ouch ) { my $app = $inst->application; warn "you can try 'cme fix $app' to fix the warnings shown above\n"; die "Found $ouch warnings in strict mode\n" if $opt->{strict}; } return; } 1; __END__ =pod =encoding UTF-8 =head1 NAME App::Cme::Command::check - Check the configuration of an application =head1 VERSION version 1.040 =head1 SYNOPSIS # standard usage cme check popcon # read data from arbitrary file (with Config::Model::Dpkg) cme check dpkg-copyright path/to/file =head1 DESCRIPTION Checks the content of the configuration file of an application. Prints warnings and errors on STDOUT. Example: cme check fstab Some applications allows one to override the default configuration file. For instance, with Debian copyright model, you can run cme on a different file: cme check dpkg-copyright foobar or directly check copyright data on STDIN: curl http://metadata.ftp-master.debian.org/changelogs/main/f/frozen-bubble/unstable_copyright \ | cme check dpkg-copyright - =head1 Common options See L. =head1 options =over =item -strict When set, cme exits 1 if warnings are found. By default, C exits 0 when warnings are found. =back =head1 EXIT CODE cme exits 0 when no errors are found. Exit 1 otherwise. If C<-strict> option is set, cme exits 1 when warnings are found. =head1 SEE ALSO L =head1 AUTHOR Dominique Dumont =head1 COPYRIGHT AND LICENSE This software is Copyright (c) 2014-2022 by Dominique Dumont . This is free software, licensed under: The GNU Lesser General Public License, Version 2.1, February 1999 =cut App-Cme-1.040/lib/App/Cme/Command/list.pm0000644000175000017500000000412414552007501016263 0ustar domidomi# # This file is part of App-Cme # # This software is Copyright (c) 2014-2022 by Dominique Dumont . # # This is free software, licensed under: # # The GNU Lesser General Public License, Version 2.1, February 1999 # # ABSTRACT: List applications handled by cme package App::Cme::Command::list ; $App::Cme::Command::list::VERSION = '1.040'; use strict; use warnings; use 5.10.1; use App::Cme -command ; use Config::Model::Lister; sub description { return << "EOD" Show a list all applications where a model is available. This list depends on installed Config::Model modules. Applications are divided in 3 categories: - system: for system wide applications (e.g. daemon like sshd) - user: for user applications (e.g. ssh configuration) - application: misc application like multistrap or Debian packaging EOD } sub opt_spec { my ( $class, $app ) = @_; return ( [ "dev!" => "list includes a model under development"], ); } my %help = ( system => "system configuration files. Use sudo to run cme", user => "user configuration files", application => "miscellaneous application configuration", ); sub execute { my ($self, $opt, $args) = @_; my ( $categories, $appli_info, $appli_map ) = Config::Model::Lister::available_models($opt->dev()); foreach my $cat ( qw/system user application/ ) { my $names = $categories->{$cat} || []; next unless @$names; print $cat," ( ",$help{$cat}," ):\n ", join( "\n ", @$names ), "\n"; } return; } 1; __END__ =pod =encoding UTF-8 =head1 NAME App::Cme::Command::list - List applications handled by cme =head1 VERSION version 1.040 =head1 SYNOPSIS cme list =head1 DESCRIPTION Show a list all applications where a model is available. This list depends on installed Config::Model modules. =head1 SEE ALSO L =head1 AUTHOR Dominique Dumont =head1 COPYRIGHT AND LICENSE This software is Copyright (c) 2014-2022 by Dominique Dumont . This is free software, licensed under: The GNU Lesser General Public License, Version 2.1, February 1999 =cut App-Cme-1.040/lib/App/Cme/Command/dump.pm0000644000175000017500000000717214552007501016263 0ustar domidomi# # This file is part of App-Cme # # This software is Copyright (c) 2014-2022 by Dominique Dumont . # # This is free software, licensed under: # # The GNU Lesser General Public License, Version 2.1, February 1999 # # ABSTRACT: Dump the configuration of an application package App::Cme::Command::dump ; $App::Cme::Command::dump::VERSION = '1.040'; use strict; use warnings; use 5.10.1; use App::Cme -command ; use base qw/App::Cme::Common/; use Config::Model::ObjTreeScanner; use YAML::PP qw/Dump/; use JSON; use Data::Dumper; sub validate_args { my ($self, $opt, $args) = @_; $self->check_unknown_args($args); $opt->{quiet} = 1; # don't want to mess up yaml output $self->process_args($opt,$args); return; } sub opt_spec { my ( $class, $app ) = @_; return ( [ "dumptype=s" => "Dump all values (full) or only customized values", { regex => qr/^(?:full|custom|non_upstream_default)$/, default => 'custom' } ], [ "format=s" => "dump using specified format (yaml json perl cml)", { regex => qr/^(?:json|ya?ml|perl|cml|cds)$/i, default => 'yaml' }, ], $class->cme_global_options, ); } sub usage_desc { my ($self) = @_; my $desc = $self->SUPER::usage_desc; # "%c COMMAND %o" return "$desc [application] [ config_file ] [ -dumptype full|custom ] [ path ]"; } sub description { my ($self) = @_; return $self->get_documentation; } sub execute { my ($self, $opt, $args) = @_; my ($model, $inst, $root) = $self->init_cme($opt,$args); my $target_node = $root->grab(step => "@$args", type => 'node'); my $dump_string; my $format = $opt->{format}; my $mode = $opt->{dumptype} || 'custom'; if ($format =~ /cml|cds/i) { $dump_string = $target_node->dump_tree( mode => $mode ); } else { my $perl_data = $target_node->dump_as_data( ordered_hash_as_list => 0, mode => $mode ); $dump_string = $format =~ /ya?ml/i ? Dump($perl_data) : $format =~ /json/i ? encode_json($perl_data) : Dumper($perl_data) ; # Perl data structure } print $dump_string ; return; } 1; __END__ =pod =encoding UTF-8 =head1 NAME App::Cme::Command::dump - Dump the configuration of an application =head1 VERSION version 1.040 =head1 SYNOPSIS # dump ~/.ssh/config in cme syntax # (this example requires Config::Model::OpenSsh) $ cme dump -format cml ssh Host:"*" - Host:"*.debian.org" User=dod - =head1 DESCRIPTION Dump configuration content on STDOUT with YAML format. By default, dump only custom values, i.e. different from application built-in values or model default values. You can use the C<-dumptype> option for other types of dump: -dumptype [ full | custom | non_upstream_default ] Choose to dump every values (full), or only customized values (default) C is like C mode, but value identical with application default are omitted. But this should seldom happen. By default, dump in yaml format. This can be changed in C, C, C (aka L format, C is also accepted) with C<-format> option. =head1 Common options See L. =head1 SEE ALSO L =head1 AUTHOR Dominique Dumont =head1 COPYRIGHT AND LICENSE This software is Copyright (c) 2014-2022 by Dominique Dumont . This is free software, licensed under: The GNU Lesser General Public License, Version 2.1, February 1999 =cut App-Cme-1.040/lib/App/Cme/Command/edit.pm0000644000175000017500000001113314552007501016233 0ustar domidomi# # This file is part of App-Cme # # This software is Copyright (c) 2014-2022 by Dominique Dumont . # # This is free software, licensed under: # # The GNU Lesser General Public License, Version 2.1, February 1999 # # ABSTRACT: Edit the configuration of an application package App::Cme::Command::edit ; $App::Cme::Command::edit::VERSION = '1.040'; use strict; use warnings; use 5.10.1; use App::Cme -command ; use base qw/App::Cme::Common/; use Config::Model::ObjTreeScanner; sub validate_args { my ($self, $opt, $args) = @_; $self->check_unknown_args($args); $self->process_args($opt,$args); return; } sub opt_spec { my ( $class, $app ) = @_; return ( [ "ui|if=s" => "user interface type. Either tk, curses, shell" ], [ "backup:s" => "Create a backup of configuration files before saving." ], [ "open-item=s" => "open a specific item of the configuration" ], $class->cme_global_options, ); } sub usage_desc { my ($self) = @_; my $desc = $self->SUPER::usage_desc; # "%c COMMAND %o" return "$desc [application] [ file ] [ -ui tk|curses|shell ] [ -open-item xxx ] "; } sub description { my ($self) = @_; return $self->get_documentation; } sub execute { my ($self, $opt, $args) = @_; my ($model, $inst, $root) = $self->init_cme($opt,$args); my $has_tk = eval { require Config::Model::TkUI; 1; }; my $has_curses = eval { require Config::Model::CursesUI; 1; }; my $ui_type = $opt->{ui}; if ( not defined $ui_type ) { if ($has_tk) { $ui_type = 'tk'; } elsif ($has_curses) { warn "You should install Config::Model::TkUI for a ", "more friendly user interface\n"; $ui_type = 'curses'; } else { warn "You should install Config::Model::TkUI or ", "Config::Model::CursesUI ", "for a more friendly user interface\n"; $ui_type = 'shell'; } } $root->deep_check; if ( $ui_type eq 'shell' ) { require Config::Model::TermUI; $self->run_shell_ui('Config::Model::TermUI', $inst) ; } elsif ( $ui_type eq 'curses' ) { die "cannot run curses interface: ", "Config::Model::CursesUI is not installed, please use shell or simple UI\n" unless $has_curses; my $err_file = '/tmp/cme-error.log'; print "In case of error, check $err_file\n"; open( my $fh, ">", $err_file ) || die "Can't open $err_file: $!\n"; open(STDERR, ">&", $fh)|| die "Can't open STDERR:$!\n"; my $dialog = Config::Model::CursesUI->new(); # engage in user interaction $dialog->start($model); close($fh); } elsif ( $ui_type eq 'tk' ) { die "cannot run Tk interface: Config::Model::TkUI is not installed, please use curses or shell or simple ui\n" unless $has_tk; $self ->run_tk_ui ( $inst, $opt); } else { die "Unsupported user interface: $ui_type\n"; } return; } 1; __END__ =pod =encoding UTF-8 =head1 NAME App::Cme::Command::edit - Edit the configuration of an application =head1 VERSION version 1.040 =head1 SYNOPSIS # edit dpkg config with GUI (requires Config::Model::Dpkg) cme edit dpkg # force usage of simple shell like interface cme edit dpkg-copyright --ui shell # edit /etc/sshd_config (requires Config::Model::OpenSsh) sudo cme edit sshd # edit ~/.ssh/config (requires Config::Model::OpenSsh) cme edit ssh # edit a file (file name specification is mandatory here) cme edit multistrap my.conf =head1 DESCRIPTION Edit a configuration. By default, a Tk GUI will be opened if C is installed. You can choose another user interface with the C<-ui> option: =over =item * C: provides a Tk graphical interface (If C is installed). =item * C: provides a curses user interface (If L is installed). =item * C: provides a shell like interface. See L for details. This is equivalent to running C command. =back =head1 Common options See L. =head1 options =over =item -open-item Open a specific item of the configuration when opening the editor. Trying to open a non-existing item triggers an error. =back =head1 SEE ALSO L =head1 AUTHOR Dominique Dumont =head1 COPYRIGHT AND LICENSE This software is Copyright (c) 2014-2022 by Dominique Dumont . This is free software, licensed under: The GNU Lesser General Public License, Version 2.1, February 1999 =cut App-Cme-1.040/lib/App/Cme/Command/fusefs.pm0000644000175000017500000000670514552007501016612 0ustar domidomi# # This file is part of App-Cme # # This software is Copyright (c) 2014-2022 by Dominique Dumont . # # This is free software, licensed under: # # The GNU Lesser General Public License, Version 2.1, February 1999 # # ABSTRACT: Edit the configuration of an application with fuse package App::Cme::Command::fusefs ; $App::Cme::Command::fusefs::VERSION = '1.040'; use strict; use warnings; use 5.10.1; use App::Cme -command ; use base qw/App::Cme::Common/; use Config::Model::ObjTreeScanner; sub validate_args { my ($self, $opt, $args) = @_; $self->check_unknown_args($args); $self->process_args($opt,$args); my $has_fuse = eval { require Config::Model::FuseUI; 1; }; die "could not load Config::Model::FuseUI. Is Fuse installed ?\n" unless $has_fuse; my $fd = $opt->{fuse_dir}; die "Directory $fd does not exists\n" unless -d $fd; return; } sub opt_spec { my ( $class, $app ) = @_; return ( [ "fuse-dir=s" => "Directory where the virtual file system will be mounted", {required => 1} ], [ "dfuse!" => "debug fuse problems" ], [ "dir-char=s" => "string to replace '/' in configuration parameter names"], [ "backup:s" => "Create a backup of configuration files before saving." ], $class->cme_global_options, ); } sub usage_desc { my ($self) = @_; my $desc = $self->SUPER::usage_desc; # "%c COMMAND %o" return "$desc [application] [file ] -fuse-dir xxx [ -dir-char x ] "; } sub description { my ($self) = @_; return $self->get_documentation; } sub execute { my ($self, $opt, $args) = @_; my ($model, $inst, $root) = $self->init_cme($opt,$args); my @extra; if (my $dc = $opt->{dir_char}) { push @extra, dir_char_mockup => $dc; } my $fuse_dir = $opt->{fuse_dir}; print "Mounting config on $fuse_dir in background.\n", "Use command 'fusermount -u $fuse_dir' to unmount\n"; my $ui = Config::Model::FuseUI->new( root => $root, mountpoint => $fuse_dir, @extra, ); # now fork my $pid = fork; if ( defined $pid and $pid == 0 ) { # child process, just run fuse and wait for exit $ui->run_loop( debug => $opt->{fuse_debug} ); $self->save($inst,$opt); } # parent process simply exits return; } 1; __END__ =pod =encoding UTF-8 =head1 NAME App::Cme::Command::fusefs - Edit the configuration of an application with fuse =head1 VERSION version 1.040 =head1 SYNOPSIS =head1 DESCRIPTION Map the configuration file content to a FUSE virtual file system on a directory specified with option C<-fuse-dir>. Modifications done in the fuse file system are saved to the configuration file when C<< fusermount -u >> is run. =head1 Common options See L. =head1 options =over =item -fuse-dir Mandatory. Directory where the virtual file system will be mounted. =item -dfuse Use this option to debug fuse problems. =item -dir-char Fuse will fail if an element name or key name contains '/'. You can specify a substitution string to replace '/' in the fused dir. Default is C<< >>. =back =head1 SEE ALSO L =head1 AUTHOR Dominique Dumont =head1 COPYRIGHT AND LICENSE This software is Copyright (c) 2014-2022 by Dominique Dumont . This is free software, licensed under: The GNU Lesser General Public License, Version 2.1, February 1999 =cut App-Cme-1.040/lib/App/Cme/Command/migrate.pm0000644000175000017500000000411714552007501016742 0ustar domidomi# # This file is part of App-Cme # # This software is Copyright (c) 2014-2022 by Dominique Dumont . # # This is free software, licensed under: # # The GNU Lesser General Public License, Version 2.1, February 1999 # # ABSTRACT: Migrate the configuration of an application package App::Cme::Command::migrate ; $App::Cme::Command::migrate::VERSION = '1.040'; use strict; use warnings; use 5.10.1; use App::Cme -command ; use base qw/App::Cme::Common/; use Config::Model::ObjTreeScanner; sub validate_args { my ($self, $opt, $args) = @_; $self->check_unknown_args($args); $self->process_args($opt,$args); return; } sub opt_spec { my ( $class, $app ) = @_; return ( [ "backup:s" => "Create a backup of configuration files before saving." ], $class->cme_global_options, ); } sub usage_desc { my ($self) = @_; my $desc = $self->SUPER::usage_desc; # "%c COMMAND %o" return "$desc [application] [file ]"; } sub description { my ($self) = @_; return $self->get_documentation; } sub execute { my ($self, $opt, $args) = @_; my ($model, $inst, $root) = $self->init_cme($opt,$args); $root->migrate; $self->save($inst,$opt) ; return; } 1; __END__ =pod =encoding UTF-8 =head1 NAME App::Cme::Command::migrate - Migrate the configuration of an application =head1 VERSION version 1.040 =head1 SYNOPSIS # check dpkg files, update deprecated parameters and save cme migrate dpkg =head1 DESCRIPTION Checks the content of the configuration file of an application (and show warnings if needed), update deprecated parameters (old value are saved to new parameters) and save the new configuration. See L. For more details, see L =head1 Common options See L. =head1 SEE ALSO L =head1 AUTHOR Dominique Dumont =head1 COPYRIGHT AND LICENSE This software is Copyright (c) 2014-2022 by Dominique Dumont . This is free software, licensed under: The GNU Lesser General Public License, Version 2.1, February 1999 =cut App-Cme-1.040/lib/App/Cme/Command/run.pm0000644000175000017500000005434014552007501016121 0ustar domidomi# # This file is part of App-Cme # # This software is Copyright (c) 2014-2022 by Dominique Dumont . # # This is free software, licensed under: # # The GNU Lesser General Public License, Version 2.1, February 1999 # # ABSTRACT: Run a cme script package App::Cme::Command::run ; $App::Cme::Command::run::VERSION = '1.040'; use strict; use warnings; use v5.20; use File::HomeDir; use Path::Tiny; use Config::Model; use Log::Log4perl qw(get_logger :levels); use YAML::PP; use Encode qw(decode_utf8); use App::Cme -command ; use base qw/App::Cme::Common/; use feature qw/postderef signatures/; no warnings qw/experimental::postderef experimental::signatures experimental::smartmatch/; my $__test_home = ''; # used only by tests ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) sub _set_test_home { $__test_home = shift; return;} my $home = $__test_home || File::HomeDir->my_home; my @script_paths = map {path($_)} ( "$home/.cme/scripts", "/etc/cme/scripts/", ); push @script_paths, path($INC{"Config/Model.pm"})->parent->child("Model/scripts") ; sub opt_spec { my ( $class, $app ) = @_; return ( [ "arg=s@" => "script argument. run 'cme run