Skip to content

Commit d17eb79

Browse files
committed
Print help by default and add option to return it as a string
1 parent 5062a23 commit d17eb79

2 files changed

Lines changed: 15 additions & 7 deletions

File tree

geosupport/function_info.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def list_functions():
9090
)
9191
return '\n'.join(s)
9292

93-
def function_help(function):
93+
def function_help(function, return_as_string=False):
9494
function = FUNCTIONS[function]
9595

9696
s = [
@@ -117,7 +117,10 @@ def function_help(function):
117117

118118
s = "\n".join(s)
119119

120-
return s
120+
if return_as_string:
121+
return s
122+
else:
123+
print(s)
121124

122125
def input_help():
123126
s = [

geosupport/geosupport.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,18 @@ def __getattr__(self, name):
129129
def __getitem__(self, name):
130130
return self.__getattr__(name)
131131

132-
def help(self, name=None):
132+
def help(self, name=None, return_as_string=False):
133133
if name:
134134
if name.upper() == 'INPUT':
135-
return input_help()
135+
return_val = input_help()
136136
try:
137-
return function_help(name)
137+
return_val = function_help(name, return_as_string)
138138
except KeyError:
139-
return "Function '%s' does not exist." % name
139+
return_val = "Function '%s' does not exist." % name
140140
else:
141-
return list_functions()
141+
return_val = list_functions()
142+
143+
if return_as_string:
144+
return return_val
145+
elif return_val:
146+
print(return_val)

0 commit comments

Comments
 (0)