forked from 0install/0install
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path0alias
More file actions
executable file
·63 lines (52 loc) · 2.34 KB
/
0alias
File metadata and controls
executable file
·63 lines (52 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env python
# Copyright (C) 2010, Thomas Leonard
# See the README file for details, or visit http://0install.net.
from __future__ import print_function
import locale
import logging
from logging import warn
try:
locale.setlocale(locale.LC_ALL, '')
except locale.Error:
warn('Error setting locale (eg. Invalid locale)')
import sys
## PATH ##
from optparse import OptionParser
from zeroinstall import _
parser = OptionParser(usage="usage: %prog [options] alias [interface [main]]")
parser.add_option("-c", "--command", help="the command the alias will run (default 'run')", metavar='COMMNAD')
parser.add_option("-m", "--manpage", help="show the manual page for an existing alias", action='store_true')
parser.add_option("-r", "--resolve", help="show the URI for an alias", action='store_true')
parser.add_option("-v", "--verbose", help="more verbose output", action='count')
parser.add_option("-V", "--version", help="display version information", action='store_true')
#parser.add_option("-d", "--dir", help="install in DIR", dest="user_path", metavar="DIR")
(options, args) = parser.parse_args()
if options.verbose:
logger = logging.getLogger()
if options.verbose == 1:
logger.setLevel(logging.INFO)
else:
logger.setLevel(logging.DEBUG)
hdlr = logging.StreamHandler()
fmt = logging.Formatter("%(levelname)s:%(message)s")
hdlr.setFormatter(fmt)
logger.addHandler(hdlr)
if options.version:
import zeroinstall
print("0alias (zero-install) " + zeroinstall.version)
print("Copyright (C) 2010 Thomas Leonard")
print("This program comes with ABSOLUTELY NO WARRANTY,")
print("to the extent permitted by law.")
print("You may redistribute copies of this program")
print("under the terms of the GNU Lesser General Public License.")
print("For more information about these matters, see the file named COPYING.")
sys.exit(0)
if options.manpage:
print(_('ERROR: "0alias --manpage" has been removed; use "0install man" instead'), file = sys.stderr)
elif len(args) == 0:
print(_('ERROR: "0alias" has been removed; use "0install add" instead'), file = sys.stderr)
elif len(args) == 1:
print(_('ERROR: "0alias" has been removed; use "0install update" instead:\n0install update alias:%s') % args[0], file = sys.stderr)
else:
print(_('ERROR: "0alias" has been removed; use "0install add" instead:\n0install add %s %s') % (args[0], args[1]), file = sys.stderr)
sys.exit(1)