summaryrefslogtreecommitdiffstats
path: root/ipalib/cli.py
Commit message (Collapse)AuthorAgeFilesLines
* ipalib: pass api instance into textui in doctest snippetsMilan KubĂ­k2015-07-101-12/+13
| | | | Reviewed-By: Tomas Babej <tbabej@redhat.com>
* add option to skip client API version checkMartin Babinsky2015-07-081-1/+0
| | | | | | | | | This can be either set in IPA config file or specified as 'ipa --skip-version-check [COMMAND]'. part of https://fedorahosted.org/freeipa/ticket/4768 Reviewed-By: Martin Basti <mbasti@redhat.com>
* plugable: Pass API to plugins on initialization rather than using set_apiJan Cholasta2015-07-011-1/+1
| | | | | | https://fedorahosted.org/freeipa/ticket/3090 Reviewed-By: Martin Babinsky <mbabinsk@redhat.com>
* plugable: Load plugins only from modules imported by APIJan Cholasta2015-07-011-2/+1
| | | | | | | | Previously all plugin modules imported from anywhere were added to the API. https://fedorahosted.org/freeipa/ticket/3090 Reviewed-By: Martin Babinsky <mbabinsk@redhat.com>
* Do not print traceback when pipe is brokenGabe2015-06-021-1/+4
| | | | | | https://fedorahosted.org/freeipa/ticket/2284 Reviewed-By: Martin Basti <mbasti@redhat.com>
* Allow ipa help command to run when ipa-client-install is not configuredGabe2015-06-021-1/+1
| | | | | | https://fedorahosted.org/freeipa/ticket/3584 Reviewed-By: Martin Basti <mbasti@redhat.com>
* cli: differentiate Flag a Bool when autofill is setPetr Vobornik2015-05-121-2/+2
| | | | | | | | | | | With previous behavior there was no difference between Flag and Bool if - autofill == True - default = some value It prevented to have a boolean which is set by default to true, but could be set to False if users wants to without prompting in interactive shell. Reviewed-By: Martin Basti <mbasti@redhat.com>
* CLI conversion of DNSName typeMartin Basti2014-06-031-0/+3
| | | | | | | | Part of ticket: IPA should allow internationalized domain names https://fedorahosted.org/freeipa/ticket/3169 Reviewed-By: Jan Cholasta <jcholast@redhat.com>
* ipalib.cli: Add filename argument to ipa consolePetr Viktorin2014-05-221-6/+25
| | | | | | | | | This allows writing simple IPA scripts using the shebang #! /usr/bin/ipa console https://fedorahosted.org/freeipa/ticket/4351 Reviewed-By: Nathaniel McCallum <npmccallum@redhat.com>
* ipalib: Add DateTime parameterTomas Babej2014-05-051-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adds a parameter that represents a DateTime format using datetime.datetime object from python's native datetime library. In the CLI, accepts one of the following formats: Accepts LDAP Generalized time without in the following format: '%Y%m%d%H%M%SZ' Accepts subset of values defined by ISO 8601: '%Y-%m-%dT%H:%M:%SZ' '%Y-%m-%dT%H:%MZ' '%Y-%m-%dZ' Also accepts above formats using ' ' (space) as a separator instead of 'T'. As a simplification, it does not deal with timezone info and ISO 8601 values with timezone info (+-hhmm) are rejected. Values are expected to be in the UTC timezone. Values are saved to LDAP as LDAP Generalized time values in the format '%Y%m%d%H%SZ' (no time fractions and UTC timezone is assumed). To avoid confusion, in addition to subset of ISO 8601 values, the LDAP generalized time in the format '%Y%m%d%H%M%SZ' is also accepted as an input (as this is the format user will see on the output). Part of: https://fedorahosted.org/freeipa/ticket/3306 Reviewed-By: Jan Cholasta <jcholast@redhat.com>
* Allow primary keys to use different type than unicode.Jan Cholasta2014-04-181-1/+2
| | | | | | | | | | Also return list of primary keys instead of a single unicode CSV value from LDAPDelete-based commands. This introduces a new capability 'primary_key_types' for backward compatibility with old clients. Reviewed-By: Tomas Babej <tbabej@redhat.com>
* cli: Add mechanism for deprecated option name aliasesPetr Viktorin2014-03-211-14/+28
| | | | | | | | | Add a new Param kwarg, deprecated_cli_aliases, that lists deprecated aliases. The aliases will appear in a "Deprecated options" in the help, and otherwise act as the normal variant. Preparation for: https://fedorahosted.org/freeipa/ticket/4231
* cli: Show list of values in --help for all EnumsPetr Viktorin2014-03-211-4/+4
| | | | | | Previously only the StrEnum param type had the list of values listed in the help. Extend the functionality to any kind of Enum.
* cli: Clean up importsPetr Viktorin2014-03-211-6/+3
|
* cli.print_attribute: Convert values to stringsPetr Viktorin2014-01-031-1/+1
| | | | | | | | When output_for_cli was called directly, rather than for values received through XML or JSON API, joining multiple values failed on non-strings such as DN objects. Convert output to strings before printing it out.
* Changed CLI to allow to use FILE as optional paramMartin Basti2013-12-021-5/+7
|
* Help plugin: don't fail if a topic's module is not foundPetr Viktorin2013-10-301-3/+8
| | | | | | | | Previously the help plugin failed when searching for the docstring when a topic's module was not found. This can happen when some server plugins are loaded (e.g. for tests). Use empty documentation when the topic is not found.
* Add prompt_param method to avoid code duplicationTomas Babej2013-06-051-13/+12
| | | | | | | | | | Extracted common code from ipalib/plugins/cli.py and ipalib/plugins/dns.py that provided way to prompt user for the value of specific attribute. Added prompt_param method to Command class in ipalib/frontend.py Done as part of https://fedorahosted.org/freeipa/ticket/3602
* Remove redundant check for env.interactiveTomas Babej2013-06-051-1/+0
| | | | | Fixed as part of https://fedorahosted.org/freeipa/ticket/3602
* Display full command documentation in online helpPetr Viktorin2013-04-031-1/+17
| | | | | | | | | | ipa <command> -h only showed the summary string, not the full help. Use the full docstring. Add a custom help formatter that disables optparse's reformatting. Test included https://fedorahosted.org/freeipa/ticket/3543
* Fix internal error for ipa show-mappingsAna Krivokapic2013-03-181-1/+1
| | | | | | The run() method of the show_mappings command was missing the **options parameter in its signature, causing the ipa show-mappings to fail with an internal error.
* cli: Do interactive prompting after a context is createdPetr Viktorin2013-02-261-3/+3
| | | | | | | | | | Some commands require a connection for interactive prompting. Prompt after the connection is created. Option parsing is still done before connecting so that help can be printed out without a Kerberos ticket. https://fedorahosted.org/freeipa/ticket/3453
* Drop support for CSV in the CLI clientPetr Viktorin2013-02-221-1/+0
| | | | | Ticket: https://fedorahosted.org/freeipa/ticket/3352 Design: http://freeipa.org/page/V3/Drop_CSV
* Add the version option to all CommandsPetr Viktorin2013-02-211-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | Several Commands were missing the 'version' option. Add it to those that were missing it. Do not remove the version option before calling commands. This means methods such as execute(), forward(), run() receive it. Several of these needed `**options` added to their signatures. Commands in the Cert plugin passed any unknown options to the underlying functions, these are changed to pass what's needed explicitly. Some commands in DNS and Batch plugins now pass version to commands they call. When the option is not given, fill it in automatically. (In a subsequent commit, a warning will be added in this case). Note that the public API did not change: all RPC calls already accepted a version option. There's no need for an API version bump (even though API.txt changes substantially). Design page: http://freeipa.org/page/V3/Messages Tickets: https://fedorahosted.org/freeipa/ticket/2732 https://fedorahosted.org/freeipa/ticket/3294
* Run interactive_prompt callbacks after CSV values are split.Jan Cholasta2013-02-191-8/+8
| | | | https://fedorahosted.org/freeipa/ticket/3334
* In topic help text, mention how to get help for commandsPetr Viktorin2013-02-181-0/+3
| | | | | | | This should prevent user confusion when topic help is requested unintentionally, for example with `ipa help ping`. See https://fedorahosted.org/freeipa/ticket/3247
* Parse command arguments before creating a contextPetr Viktorin2013-02-181-1/+1
| | | | | | | This allows users to run `ipa COMMAND --help` even without Kerberos credentials. Part of the effort for https://fedorahosted.org/freeipa/ticket/3060
* Mention `ipa COMMAND --help` as the preferred way to get command helpPetr Viktorin2013-02-181-1/+4
| | | | | | | | | This avoids the problem with ambiguous command/topic names. No functionality is changed; `ipa help <COMMAND>` still works as before if there's no topic with the same name. https://fedorahosted.org/freeipa/ticket/3247
* Add command summary to `ipa COMMAND --help` outputPetr Viktorin2013-02-181-2/+2
| | | | | | This makes the output identical to `ipa help COMMAND`. Part of the effort for https://fedorahosted.org/freeipa/ticket/3060
* Simplify `ipa help topics` outputPetr Viktorin2013-02-181-10/+3
| | | | | | | This brings the output closer to `ipa help commands` and removes extraneous information. Part of the effort for https://fedorahosted.org/freeipa/ticket/3060
* Store the OptionParser in the API, use it to print unified help messagesPetr Viktorin2013-02-181-7/+4
| | | | | | | | | Make `ipa -h` and `ipa help` output the same message. Since `ipa -h` output is generated by the OptionParser, we need to make the parser available. Store it in `api.parser`. Part of the effort for https://fedorahosted.org/freeipa/ticket/3060
* Print help to stderr on errorPetr Viktorin2013-02-181-30/+46
| | | | | | | | | | | Whenever a command is used incorrectly, it should output an error message (and possibly additional help) to stderr. This patch adds a parameter to a bunch of places to allow selecting either stdout or stderr for help output, and makes badly called commands output to stderr only. Part of the effort for https://fedorahosted.org/freeipa/ticket/3060
* Internationalization for public errorsPetr Viktorin2012-09-031-1/+1
| | | | | | | | | | | | Currently, we throw many public exceptions without proper i18n. Wrap natural-language error messages in _() so they can be translated. In the service plugin, raise NotFound errors using handle_not_found helper so the error message contains the offending service. Use ScriptError instead of NotFoundError in bindinstance install. https://fedorahosted.org/freeipa/ticket/1953
* Rework the CallbackInterfacePetr Viktorin2012-06-141-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix several problems with the callback interface: - Automatically registered callbacks (i.e. methods named exc_callback, pre_callback etc) were registered on every instantiation. Fix: Do not register callbacks in __init__; instead return the method when asked for it. - The calling code had to distinguish between bound methods and plain functions by checking the 'im_self' attribute. Fix: Always return the "default" callback as an unbound method. Registered callbacks now always take the extra `self` argument, whether they happen to be bound methods or not. Calling code now always needs to pass the `self` argument. - Did not work well with inheritance: due to the fact that Python looks up missing attributes in superclasses, callbacks could get attached to a superclass if it was instantiated early enough. * Fix: Instead of attribute lookup, use a dictionary with class keys. - The interface included the callback types, which are LDAP-specific. Fix: Create generic register_callback and get_callback mehods, move LDAP-specific code to BaseLDAPCommand Update code that calls the callbacks. Add tests. Remove lint exceptions for CallbackInterface. * https://fedorahosted.org/freeipa/ticket/2674
* Add CLI parsing testsPetr Viktorin2012-03-281-4/+20
| | | | | | | These test that command lines are parsed to correct Command arguments. Includes some tests for interactive prompts. To make this possible cli.run is broken up into several pieces.
* Fix the procedure for getting default values of command parameters.Jan Cholasta2012-03-281-4/+4
| | | | | | | The parameters used in default_from of other parameters are now properly validated before the default_from is called. ticket 1847
* Only split CSV in the client, quote instead of escapingPetr Viktorin2012-03-201-1/+2
| | | | | | | | | | | | | | | | | Splitting on commas is not an idempotent operation: 'a,b\,c' -> ('a', 'b,c') -> ('a', 'b', 'c') That means we can't do it when the call is forwarded, so this is only done on the CLI. The UI already sends values as a tuple. Replace escaping in the csv parser with quoting. Quoted strings can have embedded commas instead of having to escape them. This prevents the csv parser from eating all escape characters. Also, document Param's csv arguments, and update tests. https://fedorahosted.org/freeipa/ticket/2417 https://fedorahosted.org/freeipa/ticket/2227
* Ignore case in yes/no promptsMartin Kosek2012-03-071-1/+1
| | | | | | | | | We did not accept answers like "Yes", "YES", "No", etc. as valid answers to yes/no prompts (used for example in dnsrecord-del interactive mode). This could confuse users. This patch changes the behavior to ignore the answer case. https://fedorahosted.org/freeipa/ticket/2484
* Improve dnsrecord interactive helpMartin Kosek2012-03-011-1/+5
| | | | | | | | | | | | | | | | | | | | | Add 2 new features to DNS record interactive help to increase its usability and also make its behavior more consistent with standard parameter interactive help: 1) Ask for missing DNS parts When a required part of a newly added DNS record was missing, we just returned a ValidationError. Now, the interactive help rather asks for all missing required parts of all DNS records that were being added by its parts. 2) Let user amend invalid part When an interactive help asked for a DNS record part value and user enters an invalid value, the entire interactive help exits with an error. This may upset a user if he already entered several correct DNS record part values. Now, the help rather tells user what's wrong and give him an opportunity to amend the value. https://fedorahosted.org/freeipa/ticket/2386
* Add common helper for interactive promptsPetr Viktorin2012-02-191-29/+30
| | | | | | | | | | | | | | | This patch adds a common method, textui.prompt_helper, that handles encoding, decoding and error handling for interactive prompts. On EOFError (Ctrl+D) or KeyboardInterrupt (Ctrl+C), it raises a new InvocationError, PromptFailed. The helper is used in prompt, prompt_yesno, and prompt_password, each of which originally only handled one of Ctrl+C and Ctrl+D. This fixes https://fedorahosted.org/freeipa/ticket/2345 And it means prompt_yesno will no longer return None on error. A minor fix restores errors.py's ability print out the list of errors when run as a script.
* Base64-decode unicode values in Bytes parameters.Jan Cholasta2012-02-131-5/+1
| | | | | | | | | | | Fix wrong handling of strings in --setattr/--addattr/--delattr. These changes make it possible to use Bytes in --setattr/--addattr/ --delattr without errors. Fixes managing SSH keys on command-line https://fedorahosted.org/freeipa/ticket/754
* Add argument help to CLIMartin Kosek2012-02-061-9/+81
| | | | | | | | | | | | CLI command help contains a documentation for all options that can be passed to commands. However, help strings for positional arguments are not included. This patch uses an OptionParser description field to list all command arguments as OptionParser does not have a native support to provide such information to user. https://fedorahosted.org/freeipa/ticket/1974
* Improve migration helpMartin Kosek2012-02-031-1/+1
| | | | | | | | | Improve migration help topic so that it easier understandable: - Add missing list of Topic commands - Add one more example to demonstrate migration abilities - Add breaks to too long lines to improve readibility https://fedorahosted.org/freeipa/ticket/2174
* Improve CLI output for complex commandsMartin Kosek2012-01-121-4/+23
| | | | | | | | | | | | | | | Complex commands may have many options or non-standard output. This patch adds 2 improvements to handle these commands better: 1) Add "option_group" parameter attribute Make command help more readable by specifying an option group for the parameter. All parameters in the same option group are then placed to one named option group 2) Allow nested entries in the output Current CLI output module cannot handle a list of nested entries (dictionaries) contained in an entry attribute. Make sure they are printed properly (with indentation) https://fedorahosted.org/freeipa/ticket/2082
* Finalize plugin initialization on demand.Jan Cholasta2011-11-221-2/+2
| | | | | | | | | | | | This patch changes the way plugins are initialized. Instead of finalizing all the plugins at once, plugins are finalized only after they are accessed (currently applies to Command, Object and Attribute subclasses, only in CLI by default). This change provides significant performance boost, as only the plugins that are actually used are finalized. ticket 1336
* Fix problems in help systemmasterRob Crittenden2011-10-201-0/+8
| | | | | | | | | | Fixes 3 issues: - If a topic has all its commands disabled, it should be disabled - If a command is disabled its help should be disabled - The show-mappings help was missing a doc string so no help was displayed https://fedorahosted.org/freeipa/ticket/1998
* Unroll StrEnum values when displaying helpAlexander Bokovoy2011-10-031-1/+4
| | | | https://fedorahosted.org/freeipa/ticket/1848
* Require current password when using passwd to change your own password.Rob Crittenden2011-10-041-2/+4
| | | | | | | | | | | | | | | | | | Add a new required parameter, current_password. In order to ask this first I added a new parameter option, sortorder. The lower the value the earlier it will be prompted for. I also changed the way autofill works. It will attempt to get the default and if it doesn't get anything will continue prompting interactively. Since current_password is required I'm passing a magic value that means changing someone else's password. We need to pass something since current_password is required. The python-ldap passwd command doesn't seem to use the old password at all so I do a simple bind to validate it. https://fedorahosted.org/freeipa/ticket/1808
* ticket 1706 - internationalize cli help frameworkJohn Dennis2011-08-241-7/+7
| | | | | | | | | In cli.py is a framework for printing out help information. The command documentation being displayed is internationalized, however the text generated by the help framework itself is not internationalized. The strings output by the help subsystem need to be internationalized.
* ticket 1705 - internationalize help topicsJohn Dennis2011-08-241-5/+3
| | | | | | | | | | | | * Wrap each topic description in _() * Replace the use of if 'topic' in dir(module) with the more Pythonic and efficient getattr(module, 'topic', None) * Make sure to invoke unicode on the value returned from _() otherwise you'll get a GettextFactory instance, not a string * Clean up trailing whitespace errors