Skip to content
This repository was archived by the owner on Jan 4, 2021. It is now read-only.

Commit a1910d3

Browse files
author
totokaka
committed
Added --no-confirm
1 parent be87c91 commit a1910d3

File tree

4 files changed

+24
-13
lines changed

4 files changed

+24
-13
lines changed

mcman/mcman.py

+4
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,10 @@ def main():
236236
default=80,
237237
const=-10,
238238
help='How many entries that should be displayed, from the bottom')
239+
group.add_argument(
240+
'--no-confirm',
241+
action='store_true',
242+
help='Do not wait for confirmation, just proceede.')
239243

240244
# The top level command
241245
parser = argparse.ArgumentParser(

mcman/plugins.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ def download(self):
224224
filled_prefix=False)
225225

226226
self.prnt('', False, False)
227-
if utils.ask('Continue to download?'):
227+
if utils.ask('Continue to download?', skip=self.args.no_confirm):
228228
prefix_format = '({{part:>{}}}/{{total}}) '.format(
229229
len(str(len(plugins))))
230230

@@ -273,7 +273,7 @@ def update(self):
273273
filled_prefix=False)
274274
self.prnt('', False, False)
275275

276-
if utils.ask('Continue to update?'):
276+
if utils.ask('Continue to update?', skip=self.args.no_confirm):
277277
prefix_format = '({{part:>{}}}/{{total}}) '.format(
278278
len(str(len(to_update))))
279279

mcman/servers.py

+9-6
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# Imports from dependencies:
66
import spacegdn
77
# Imports from mcman:
8-
from mcman.utils import list_names, download, ask, checksum_file
8+
from mcman import utils
99

1010

1111
class Servers(object):
@@ -58,10 +58,13 @@ def error(self, error):
5858
def prnt_result(self, result):
5959
""" Print result. """
6060
self.prnt('Results:')
61+
self.prnt('', False, False)
6162
if len(result) > 0:
62-
self.prnt(' {}'.format(list_names(result)), filled_prefix=False)
63+
self.prnt(' {}'.format(utils.list_names(result)),
64+
filled_prefix=False)
6365
else:
6466
self.prnt(' No results...', filled_prefix=False)
67+
self.prnt('', False, False)
6568

6669
def servers(self):
6770
""" List servers. """
@@ -185,17 +188,17 @@ def download(self):
185188
filled_prefix=False)
186189
self.prnt('', False, False)
187190

188-
if ask('Continue to download?'):
189-
download(build['url'], file_name=self.args.output,
190-
checksum=build['checksum'], prefix=' '*4)
191+
if utils.ask('Continue to download?', skip=self.args.no_confirm):
192+
utils.download(build['url'], file_name=self.args.output,
193+
checksum=build['checksum'], prefix=' '*4)
191194
self.prnt('', False, False)
192195
self.prnt('Done!', prefix=False)
193196

194197
def identify(self):
195198
""" Identify what server a jar is. """
196199
self.prnt('Calculating checksum of `{}`'.format(self.args.jar.name))
197200

198-
checksum = checksum_file(self.args.jar)
201+
checksum = utils.checksum_file(self.args.jar)
199202
self.args.jar.close()
200203

201204
self.prnt('Finding build on SpaceGDN')

mcman/utils.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,15 @@ def extract_file(zipped, file, dest):
167167
dest.write(content)
168168

169169

170-
def ask(question, want_yes=True):
170+
def ask(question, want_yes=True, skip=False):
171171
""" Ask user for confirmation. """
172172
print(question, end=' [Y/n]: ' if want_yes else ' [y/N]: ')
173-
answer = input()
174-
if len(answer) == 0:
175-
return want_yes
173+
if skip:
174+
print('y')
175+
return True
176176
else:
177-
return 'y' in answer.lower()
177+
answer = input()
178+
if len(answer) == 0:
179+
return want_yes
180+
else:
181+
return 'y' in answer.lower()

0 commit comments

Comments
 (0)