#!/usr/bin/python
import sys
import os
if len(sys.argv) < 2:
print("Usage: " + sys.argv[0] + " prog")
sys.exit(0)
prog = sys.argv[1]
p = os.popen(prog + " --help")
with p:
hlp = p.read()
print("Help:\n")
helplines = hlp.split("\n")
for line in helplines:
if len(line) and (line[0] == " " or line[0] == "\t"):
line = line.strip()
if len(line) and line[0] == "-":
words = line.split(' ')
in_opts = True
str = ""
for word in words:
if in_opts:
if not len(word) or word[0] != '-':
in_opts = False
if in_opts:
str += word + "\n"
else:
str += word + " "
print(str)
# print(line)
# print(hlp)