Changeset d3761377682f…
Parent b4994d4cc1f7…
by
Changes to one file · Browse files at d3761377682f Showing diff from parent b4994d4cc1f7 Diff from another changeset...
@@ -35,10 +35,17 @@ from mercurial import commands, cmdutil, patch, ui, util
from mercurial.i18n import _
-def paste(ui, repo, nick, channel, title, **opts):
- nick = nick or ui.config('lisppaste', 'nick') or ui.prompt('nick:', default='')
- channel = channel or ui.config('lisppaste', 'channel') or ui.prompt('channel:', default='')
- title = title or ui.prompt('title:', default='')
+def paste(ui, repo, interactive, **opts):
+ def prompt(name, default):
+ if not opts.get(name) and interactive or not default:
+ msg = (default and '%s [%s]:' or '%s%s:') % (name, default)
+ return ui.prompt(msg, default=default)
+ return default
+
+ nick = prompt('nick', opts.get('nick') or ui.config('lisppaste', 'nick'))
+ channel = prompt('channel', opts.get('channel') or ui.config('lisppaste', 'channel'))
+ title = prompt('title', opts.get('title'))
+
if not nick or not channel or not title:
raise util.Abort('must specify nick, channel, and title')
rev = opts.get('rev')
@@ -58,6 +65,7 @@ [('N', 'nick', '', _('your nickname on Freenode')),
('C', 'channel', '', _('the channel to associate with the paste')),
('m', 'title', '', _('title for the paste')),
+ ('i', 'interactive', False, _('forces prompting for options')),
] + commands.diffopts + commands.diffopts2 + commands.walkopts,
_('hg paste [OPTION]')),
}
|
Loading...