Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
I
inary
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
1
Konular (issue)
1
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
SulinOS
inary
Commits
d39e75c5
Kaydet (Commit)
d39e75c5
authored
Eyl 27, 2006
tarafından
Faik Uygur
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
* svn style help output format
üst
417fcaa8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
65 additions
and
4 deletions
+65
-4
commands.py
pisi/cli/commands.py
+65
-4
No files found.
pisi/cli/commands.py
Dosyayı görüntüle @
d39e75c5
...
...
@@ -11,7 +11,7 @@
#
import
sys
from
optparse
import
OptionParser
,
OptionGroup
from
optparse
import
OptionParser
,
OptionGroup
,
HelpFormatter
import
gettext
__trans
=
gettext
.
translation
(
'pisi'
,
fallback
=
True
)
...
...
@@ -28,6 +28,67 @@ from colors import colorize
class
Error
(
pisi
.
Error
):
pass
class
PisiHelpFormatter
(
HelpFormatter
):
def
__init__
(
self
,
indent_increment
=
1
,
max_help_position
=
32
,
width
=
None
,
short_first
=
1
):
HelpFormatter
.
__init__
(
self
,
indent_increment
,
max_help_position
,
width
,
short_first
)
self
.
_short_opt_fmt
=
"
%
s"
self
.
_long_opt_fmt
=
"
%
s"
def
format_usage
(
self
,
usage
):
return
_
(
"usage:
%
s
\n
"
)
%
usage
def
format_heading
(
self
,
heading
):
return
"
%*
s
%
s:
\n
"
%
(
self
.
current_indent
,
""
,
heading
)
def
format_option_strings
(
self
,
option
):
"""Return a comma-separated list of option strings & metavariables."""
if
option
.
takes_value
():
short_opts
=
[
self
.
_short_opt_fmt
%
sopt
for
sopt
in
option
.
_short_opts
]
long_opts
=
[
self
.
_long_opt_fmt
%
lopt
for
lopt
in
option
.
_long_opts
]
else
:
short_opts
=
option
.
_short_opts
long_opts
=
option
.
_long_opts
if
long_opts
and
short_opts
:
opt
=
"
%
s [
%
s]"
%
(
short_opts
[
0
],
long_opts
[
0
])
else
:
opt
=
long_opts
[
0
]
or
short_opts
[
0
]
if
option
.
takes_value
():
opt
+=
" arg"
return
opt
def
format_option
(
self
,
option
):
import
textwrap
result
=
[]
opts
=
self
.
option_strings
[
option
]
opt_width
=
self
.
help_position
-
self
.
current_indent
-
2
if
len
(
opts
)
>
opt_width
:
opts
=
"
%*
s
%
s
\n
"
%
(
self
.
current_indent
,
""
,
opts
)
indent_first
=
self
.
help_position
else
:
# start help on same line as opts
opts
=
"
%*
s
%-*
s "
%
(
self
.
current_indent
,
""
,
opt_width
,
opts
)
indent_first
=
0
result
.
append
(
opts
)
if
option
.
help
:
help_text
=
self
.
expand_default
(
option
)
help_lines
=
textwrap
.
wrap
(
help_text
,
self
.
help_width
)
result
.
append
(
":
%*
s
%
s
\n
"
%
(
indent_first
,
""
,
help_lines
[
0
]))
result
.
extend
([
"
%*
s
%
s
\n
"
%
(
self
.
help_position
,
""
,
line
)
for
line
in
help_lines
[
1
:]])
elif
opts
[
-
1
]
!=
"
\n
"
:
result
.
append
(
"
\n
"
)
return
""
.
join
(
result
)
class
Command
(
object
):
"""generic help string for any command"""
...
...
@@ -70,7 +131,8 @@ class Command(object):
import
pisi
self
.
comar
=
False
self
.
parser
=
OptionParser
(
usage
=
getattr
(
self
,
"__doc__"
),
version
=
"
%
prog "
+
pisi
.
__version__
)
version
=
"
%
prog "
+
pisi
.
__version__
,
formatter
=
PisiHelpFormatter
())
self
.
options
()
self
.
commonopts
()
(
self
.
options
,
self
.
args
)
=
self
.
parser
.
parse_args
(
args
)
...
...
@@ -167,9 +229,8 @@ class Command(object):
def
help
(
self
):
"""print help for the command"""
print
self
.
format_name
()
+
': '
trans
=
gettext
.
translation
(
'pisi'
,
fallback
=
True
)
print
trans
.
ugettext
(
self
.
__doc__
)
+
'
\n
'
print
"
%
s:
%
s
\n
"
%
(
self
.
format_name
(),
trans
.
ugettext
(
self
.
__doc__
))
print
self
.
parser
.
format_option_help
()
def
die
(
self
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment