Commit Graph

266 Commits

Author SHA1 Message Date
Petr Viktorin
84c401f7d6 cli: Show list of values in --help for all Enums
Previously only the StrEnum param type had the list of values
listed in the help.
Extend the functionality to any kind of Enum.
2014-03-21 12:49:21 +01:00
Petr Viktorin
d2e3af88eb cli: Clean up imports 2014-03-21 12:49:21 +01:00
Petr Viktorin
7ec4d58bf7 cli.print_attribute: Convert values to strings
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.
2014-01-03 14:11:33 +01:00
Martin Basti
db7dbbb141 Changed CLI to allow to use FILE as optional param 2013-12-02 13:30:11 +01:00
Petr Viktorin
dadf7cddf0 Help plugin: don't fail if a topic's module is not found
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.
2013-10-30 11:50:05 +01:00
Tomas Babej
89ffaf411d Add prompt_param method to avoid code duplication
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
2013-06-05 12:50:29 +02:00
Tomas Babej
8984e3e105 Remove redundant check for env.interactive
Fixed as part of
https://fedorahosted.org/freeipa/ticket/3602
2013-06-05 12:50:29 +02:00
Petr Viktorin
4a30bf55ac Display full command documentation in online help
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
2013-04-03 15:32:03 +02:00
Ana Krivokapic
5f6310ecc6 Fix internal error for ipa show-mappings
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.
2013-03-18 14:40:54 +01:00
Petr Viktorin
8b8859ed7d cli: Do interactive prompting after a context is created
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
2013-02-26 18:19:16 +01:00
Petr Viktorin
3a96cbc518 Drop support for CSV in the CLI client
Ticket: https://fedorahosted.org/freeipa/ticket/3352
Design: http://freeipa.org/page/V3/Drop_CSV
2013-02-22 17:20:35 +01:00
Petr Viktorin
7336a176b4 Add the version option to all Commands
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
2013-02-21 16:26:09 +01:00
Jan Cholasta
cfbdeebe66 Run interactive_prompt callbacks after CSV values are split.
https://fedorahosted.org/freeipa/ticket/3334
2013-02-19 11:08:11 -05:00
Petr Viktorin
8fcc8bc8d5 In topic help text, mention how to get help for commands
This should prevent user confusion when topic help is requested
unintentionally, for example with `ipa help ping`.

See https://fedorahosted.org/freeipa/ticket/3247
2013-02-18 13:07:26 -05:00
Petr Viktorin
abe26d55c8 Parse command arguments before creating a context
This allows users to run `ipa COMMAND --help` even without
Kerberos credentials.

Part of the effort for https://fedorahosted.org/freeipa/ticket/3060
2013-02-18 13:07:17 -05:00
Petr Viktorin
f16c100f1e Mention ipa COMMAND --help as the preferred way to get command help
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
2013-02-18 13:07:17 -05:00
Petr Viktorin
de1c4eeae2 Add command summary to ipa COMMAND --help output
This makes the output identical to `ipa help COMMAND`.

Part of the effort for https://fedorahosted.org/freeipa/ticket/3060
2013-02-18 13:07:17 -05:00
Petr Viktorin
6ac0e9b90f Simplify ipa help topics output
This brings the output closer to `ipa help commands` and removes
extraneous information.

Part of the effort for https://fedorahosted.org/freeipa/ticket/3060
2013-02-18 13:07:17 -05:00
Petr Viktorin
5ee2216f49 Store the OptionParser in the API, use it to print unified help messages
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
2013-02-18 13:07:17 -05:00
Petr Viktorin
1e2437ece1 Print help to stderr on error
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
2013-02-18 13:07:17 -05:00
Petr Viktorin
a95eaeac8e Internationalization for public errors
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
2012-09-03 18:16:12 +02:00
Petr Viktorin
9960149e3f Rework the CallbackInterface
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
2012-06-14 11:09:43 +02:00
Petr Viktorin
96c5551ace Add CLI parsing tests
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.
2012-03-28 15:25:33 +02:00
Jan Cholasta
5a55e11a25 Fix the procedure for getting default values of command parameters.
The parameters used in default_from of other parameters are now
properly validated before the default_from is called.

ticket 1847
2012-03-28 14:03:27 +02:00
Petr Viktorin
dddebe2350 Only split CSV in the client, quote instead of escaping
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
2012-03-20 20:03:54 -04:00
Martin Kosek
480e1a098a Ignore case in yes/no prompts
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
2012-03-07 18:53:01 +01:00
Martin Kosek
1d09cdf634 Improve dnsrecord interactive help
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
2012-03-01 22:12:25 -05:00
Petr Viktorin
efb37739ab Add common helper for interactive prompts
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.
2012-02-19 20:23:20 -05:00
Jan Cholasta
ca3f304110 Base64-decode unicode values in Bytes parameters.
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
2012-02-13 22:21:50 -05:00
Martin Kosek
d4272ce374 Add argument help to CLI
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
2012-02-06 08:57:07 +01:00
Martin Kosek
b2239d533d Improve migration help
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
2012-02-03 16:39:27 +01:00
Martin Kosek
2188dae0c9 Improve CLI output for complex commands
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
2012-01-12 09:43:13 +01:00
Jan Cholasta
e7a6d10555 Finalize plugin initialization on demand.
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
2011-11-22 00:52:24 -05:00
Rob Crittenden
f098b213eb Fix problems in help system
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
2011-10-20 18:25:27 -04:00
Alexander Bokovoy
b5758c8005 Unroll StrEnum values when displaying help
https://fedorahosted.org/freeipa/ticket/1848
2011-10-03 16:40:48 -04:00
Rob Crittenden
bd227b3562 Require current password when using passwd to change your own password.
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
2011-10-04 15:16:15 +02:00
John Dennis
7746e22fe7 ticket 1706 - internationalize cli help framework
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.
2011-08-24 23:06:28 -04:00
John Dennis
a4fadbfe63 ticket 1705 - internationalize help topics
* 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
2011-08-24 23:05:17 -04:00
Rob Crittenden
1936b8050e Add option to only prompt once for passwords, use in entitle_register
A Password param always prompted to confirm the entered password.
This doesn't make sense if you want to prompt for a password to another
system like we do with entitlements. This adds a new boolean option to
control the Password prompt parameter.

https://fedorahosted.org/freeipa/ticket/1695
2011-08-24 15:25:53 -04:00
Martin Kosek
585083c1d7 Improve interactive mode for DNS plugin
Interactive mode for commands manipulating with DNS records
(dnsrecord-add, dnsrecord-del) is not usable. This patch enhances
the server framework with new callback for interactive mode, which
can be used by commands to inject their own interactive handling.

The callback is then used to improve aforementioned commands'
interactive mode.

https://fedorahosted.org/freeipa/ticket/1018
2011-06-02 09:00:35 +02:00
Jan Cholasta
6c66d37655 Assume ipa help for plugins.
ticket 914
2011-05-13 13:25:34 -04:00
Jan Cholasta
7e0d4531c3 Several improvements of the lint script.
Report missing python packages, inform about false positives, fail
gracefully if pylint isn't installed. Fixed a bug in the ignore
list and added few more files/directories to it.

ticket 1184
2011-05-05 11:54:07 +02:00
Jan Cholasta
1ac3ed2c27 Fix lint false positives. 2011-04-13 15:58:45 +02:00
Pavel Zuna
fc842e3650 Use pygettext to generate translatable strings from plugin files.
This patch replaces xgettext with a custom pygettext to generate
translatable strings from plugin files in ipalib/plugins. pygettext
was modified to handle plural forms (credit goes to Jan Hendrik Goellner)
and had some bugs fixed by myself. We only use it for plugins, because
it's the only place where we need to extract docstrings for the built-in
help system.

I also had to make some changes to the way the built-in documentation
systems gets docstrings from modules for this to work.
2011-03-01 10:31:42 -05:00
Pavel Zuna
8145952752 Translate docstrings. 2011-03-01 10:31:39 -05:00
Jan Zeleny
da1fe966de Fixed type of argument in class help 2011-02-14 10:32:37 -05:00
Jan Zeleny
978be50666 Provide a way to display CLI-LDAP relation
Since some LDAP attributes have their cli_name value defined,
so they can be more user friendly, it can be difficult for user to find
out which attributes do the parameteres given to CLI really represent.
This patch provides new command, which will take another IPA command as
and argument and display attributes which given command takes and what
LDAP attributes are they mapped to.

https://fedorahosted.org/freeipa/ticket/447
2011-02-10 15:11:26 -05:00
Pavel Zuna
dba751758c Fix crash in ipa help for NO_CLI plugins.
Fix #854
2011-02-02 10:47:53 -05:00
Rob Crittenden
275998f6bd Add support for tracking and counting entitlements
Adds a plugin, entitle, to register to the entitlement server, consume
entitlements and to count and track them. It is also possible to
import an entitlement certificate (if for example the remote entitlement
server is unaviailable).

This uses the candlepin server from https://fedorahosted.org/candlepin/wiki
for entitlements.

Add a cron job to validate the entitlement status and syslog the results.

tickets 28, 79, 278
2011-02-02 10:00:38 -05:00
Rob Crittenden
5c88225dda Add brackets around optional parameters when prompting.
ticket 832
2011-01-25 17:08:57 -05:00
Jakub Hrozek
ab2ca8022e Fix assorted bugs found by pylint 2011-01-25 14:01:36 -05:00
Pavel Zuna
0c2beda3f7 Fix crash when displaying values composed of white-space chars only in CLI.
Ticket #825
2011-01-24 22:44:15 -05:00
Rob Crittenden
4361cd0242 Rename INTERNAL to NO_CLI for commands we hide from the cli.
Also make i18n_messages and json_metadata NO_CLI.

ticket 821
2011-01-21 13:56:02 -05:00
Jan Zeleny
6d01bf037d Make command syntax less confusing in help
The patch adds [options] to the syntax line of ipa help <command>

https://fedorahosted.org/freeipa/ticket/733
2011-01-21 10:56:03 -05:00
Rob Crittenden
c69d8084c1 Add API version and have server reject incompatible clients.
This patch contains 2 parts.

The first part is a small utility to create and validate the current
API. To do this it needs to load ipalib which on a fresh system
introduces a few problems, namely that it relies on a python plugin
to set the default encoding to utf8. For our purposes we can skip that.
It is also important that any optional plugins be loadable so the
API can be examined.

The second part is a version exchange between the client and server.
The version has a major and a minor version. The major verion is
updated whenever existing API changes. The minor version is updated when
new API is added. A request will be rejected if either the major versions
don't match or if the client major version is higher than then server
major version (though by implication new API would return a command not
found if allowed to proceed).

To determine the API version of the server from a client use the ping
command.

ticket 584
2011-01-14 14:26:22 -05:00
Rob Crittenden
c7789199f9 Fix output of failed managedby hosts, allow a host to manage itself.
The output problem was a missing label for failed managedby.

This also fixes a call to print_entry that was missing the flags argument.

Add a flag to specify whether a group can be a member of itself, defaulting
to False.

ticket 708
2011-01-11 10:23:31 -05:00
Rob Crittenden
6f58f38748 Display the entries that failed when deleting with --continue.
We collected the failures but didn't report it back. This changes the
API of most delete commands so rather than returning a boolean it returns
a dict with the only current key as failed.

This also adds a new parameter flag, suppress_empty. This will try to
not print values that are empty if included. This makes the output of
the delete commands a bit prettier.

ticket 687
2011-01-10 10:32:10 -05:00
Jan Zeleny
6214af8a8d Changed concept of ipa help
The concept is now following:
topic:    either a module or a group of modules containing registered
          commands. All these commands will usually handle common entity
          type (e.g. hbac rules)
subtopic: each topic can have a number of subtopics. In this case topic
          is a group of modules and each module represents a subtopic.

grouping modules to topics is possible by assigning a 2-tuple to module
variable:

topic = ('topic-name','topic description')

The topic description has to be the same in all modules in the topic.
These are examples of commands now available in IPA help:

ipa help              - display a list of all topics
ipa help hbac         - display help for hbac topic
ipa help hbacrule     - display help for a subtopic of hbac
ipa help hbacrule-add - display help for a particular command

https://fedorahosted.org/freeipa/ticket/410
2011-01-07 09:42:38 -05:00
Jakub Hrozek
7493d781df Change FreeIPA license to GPLv3+
The changes include:
 * Change license blobs in source files to mention GPLv3+ not GPLv2 only
 * Add GPLv3+ license text
 * Package COPYING not LICENSE as the license blobs (even the old ones)
   mention COPYING specifically, it is also more common, I think

 https://fedorahosted.org/freeipa/ticket/239
2010-12-20 17:19:53 -05:00
Rob Crittenden
5b7abefb42 If any params marked alwaysask are provided then prompt for none of them.
ticket 604
2010-12-09 15:06:42 -05:00
Rob Crittenden
a41e69fba3 Add labels for passwords, fix output of exceptions, fix passwd output.
Passwords didn't have internationalizable labels.

Exceptions that occured during required input weren't printed as unicode
so weren't being translated properly.

Don't use output_for_cli() directly in the passwd plugin, use output.Output.

ticket 352
2010-12-02 16:31:42 -05:00
Rob Crittenden
df592c6cc8 Use better description for group names in help and always prompt for members
When running <foo>-[add|remove]-member completely interactively it didn't
prompt for managing membership, it just reported that 0 members were
handled which was rather confusing.

This will work via a shell if you want to echo too:

$ echo "" | ipa group-add-member g1

This returns 0 members because nothing is read for users or group members.

$ echo -e "g1\nadmin\n" | ipa group-add-member

This adds the user admin to the group g1. It adds it as a user because
user membership is prompted for first.

ticket 415
2010-12-02 16:21:31 -05:00
Pavel Zuna
94957c8ddc Prompt correctly for required Password params.
Ticket #361
2010-11-30 15:14:28 -05:00
Rob Crittenden
1db42b5461 Don't include INTERNAL commands in ipa help commands output.
ticket 463
2010-11-10 20:20:29 -05:00
Rob Crittenden
3c795f3251 Return reason for failure when updating group membership fails.
We used to return a list of dns that failed to be added. We now return
a list of tuples instead. The tuple looks like (dn, reason) where reason
is the exception that was returned.

Also made the label we use for failures to be singular instead of plural
since we now print them out individually instead of as comma-separated.

ticket 270
2010-10-28 17:47:20 -04:00
Rob Crittenden
6220b53893 Set default encoding to utf-8, use unicode when printing output.
The Gettext() object only does the lookup when you print it as a unicode.

ticket 308
2010-10-22 21:39:53 -04:00
Rob Crittenden
0ceba59d87 Add Requires on ipa-client to ipa-admintools, ensure ipa client is configured
It makes little sense to install ipa-admintools without ipa-client, require it.

Also see if the client has been configured. This is a bit tricky since we
have a full set of defaults. Add a new env option that gets set if at least
one configuration file is loaded.

ticket 213
2010-10-15 15:03:51 -04:00
Rob Crittenden
47f849ec21 Try to make topic help less confusing. Rename Related to Topic commands.
Also don't print the commands at the bottom if the plugin implements
only one command, like the passwd plugin.

ticket 105
2010-09-23 12:04:13 -04:00
Rob Crittenden
1df10a88cd Add support for client failover to the ipa command-line.
This adds a new global option to the ipa command, -f/--no-fallback. If this
is included then just the server configured in /etc/ipa/default.conf is used.
Otherwise that is tried first then all servers in DNS with the ldap SRV record
are tried.

Create a new Local() Command class for local-only commands. The help
command is one of these. It shouldn't need a remote connection to execute.

ticket #15
2010-08-16 10:35:27 -04:00
Pavel Zuna
c7a35f95c5 Fix output for commands that do not return entries.
I also changed the default value of the print_all argument in
textui.print_entry from False to True. It think it makes more sense this
way, because:

1) if order is None, it will still print something
2) if order is not None, it will print what's in order first and then the
   rest
3) commands that care about the print_all argument have to set it in any
   case, those that don't care usually want to print everything
2010-03-26 16:56:47 -04:00
Pavel Zuna
43ab2c483d Add INTERNAL flag to frontend plugins. If set, the plugin won't show in UI. 2010-03-22 10:41:36 -04:00
John Dennis
b75d06e189 localize doc strings
A number of doc strings were not localized, wrap them in _().
Some messages were not localized, wrap them in _()

Fix a couple of failing tests:
The method name in RPC should not be unicode.
The doc attribute must use the .msg attribute for comparison.

Also clean up imports of _() The import should come from
ipalib or ipalib.text, not ugettext from request.
2010-03-08 21:10:36 -07:00
John Dennis
789cba4378 fix bug 570392, command help traceback
As a consequence of using doc=_('some message') the _()
method was returning a Gettext instance, thus when optparse
was handed the help text it received a Gettext instance instead
of a basestring. optparse tried to operate on the Gettext instance
as if it were a basestring and since it wasn't threw an exception.
The fix is to promote (e.g. cast) the option.doc to unicode.
If the option.doc was a str it becomes unicode, if it was unicode
nothing happens, if it was Gettext (or any other object implementing
the __unicode__() method) object is converted to unicode via the
objects rules.

By the way, while debugging this I discovered strings which were not
localized, sometimes option.doc would be a str and sometimes a Gettext
object. In a subsequent patch I'll fix all those unlocalized doc
strings, but I don't want to bury this fix along with a load of
string fixes.
2010-03-05 10:03:41 -05:00
Jason Gerard DeRose
47f2e618f9 Fix non XML-RPC tests 2010-02-19 18:10:37 -05:00
Rob Crittenden
3fd098bb60 Used named variables in calls to print_attribute() 2010-02-17 12:05:01 -05:00
Rob Crittenden
63b55307e5 Reverse patch to not encode int values, handled at OID level properly now. 2010-02-17 09:13:50 -07:00
Pavel Zuna
03967f62e9 Auto-generate --all and --raw for commands, that return entries. 2010-02-17 10:56:06 -05:00
Rob Crittenden
7ccac40175 Don't base64-encode integers
This is a temporary fix until we either use Params to determine
output type or treat integers differently from other binary values
internally (as unicode instead of str, for example).
2010-02-17 04:13:15 -07:00
Rob Crittenden
58746226d4 Use the Output tuple to determine the order of output
The attributes displayed is now dependant upon their definition in
a Param. This enhances that, giving some level of control over how
the result is displayed to the user.

This also fixes displaying group membership, including failures of
adding/removing entries.

All tests pass now though there is still one problem. We need to
return the dn as well. Once that is fixed we just need to comment
out all the dn entries in the tests and they should once again
pass.
2010-02-15 13:10:11 -07:00
Rob Crittenden
8ca97cdf35 Base64-encode binary values on the command-line 2010-02-02 14:02:42 -05:00
Pavel Zuna
cfe47a3553 Temporary fix for name collision of textui.print_entry.
Somehow there's two of them... rename old one to print_entry1.
2010-01-20 16:53:28 -05:00
Jason Gerard DeRose
b6e4972e7f Take 2: Extensible return values and validation; steps toward a single output_for_cli(); enable more webUI stuff 2009-12-10 08:29:15 -07:00
Pavel Zuna
973f36c496 Fix Bool parameter type. It was impossible to set it to FALSE. 2009-11-30 13:38:23 -05:00
Pavel Zuna
582228714e Print only one line of docstrings in command listings.
Full docstring is shown on `ipa help COMMAND`.
2009-11-30 13:25:19 -05:00
Rob Crittenden
1d1d82fda4 Fix typo in name of exception 2009-11-12 17:34:19 -05:00
Pavel Zuna
566a3cb972 Add 'File' parameter type.
Accepts filenames and loads file contents as parameter value.
2009-11-06 16:05:31 -07:00
Pavel Zuna
04c5b5ae42 Fix bug in print_attribute.
When the attribute had no values an exception was generated while
trying to word-wrap it.
2009-10-23 09:37:23 -04:00
Jason Gerard DeRose
5c9437b9e6 Removed util.add_global_options() and frontend.Application 2009-10-14 15:07:17 -06:00
Jason Gerard DeRose
f58ff2921d Giant webui patch take 2 2009-10-13 11:28:00 -06:00
Pavel Zuna
e01b1b8f99 Fix unit tests for plugins using baseldap classes. 2009-10-05 15:59:09 -04:00
Pavel Zuna
34970fef5e Improve attribute printing in the CLI.
- allow choice between single/multiple value per line
- word wrapping
2009-09-08 13:41:54 -04:00
Jason Gerard DeRose
c0f558d98b Removed PluginProxy and all its uses 2009-08-05 12:18:51 -04:00
Jason Gerard DeRose
22493eef21 Fix three broken unit tests 2009-08-04 00:21:26 -06:00
Pavel Zuna
104d02e167 Enable attribute re-mapping and ordering when printing entries.
Also print multiple values on one line separated by commas.
2009-08-03 22:56:06 -06:00
Rob Crittenden
c0b6a78040 Require a password only once when it is passed in via a pipe 2009-07-10 16:47:35 -04:00
Rob Crittenden
d6e1e15fcd Add a one-character option for parameters 2009-07-10 16:46:34 -04:00
Rob Crittenden
fe84ffd0f1 Add a return value to exceptions.
Returning the exception value doesn't work because a shell return value
is in the range of 0-255.

The default return value is 1 which means "something went wrong." The only
specific return value implemented so far is 2 which is "not found".
2009-07-10 16:44:54 -04:00
Rob Crittenden
0e29dd7226 Add textui function to display and prompt user for selection for *-find.
Since we may end up executing a *-show when an entry is selected we need
to defer destroying the connection context.
2009-07-10 16:44:22 -04:00
Rob Crittenden
e46fd3401e Two new arguments for the help built-in command: topics and commands
ipa help topics will show all topics (equivalent to ipa help)
ipa help commands will show list of all available commands
2009-06-15 14:03:12 -04:00
Rob Crittenden
fe012f4ff2 Fix a few issues introduced by the new Param.use_in_context() patch 2009-05-21 14:33:23 -04:00