diff options
author | Karel Kočí <cynerd@email.cz> | 2016-01-08 16:09:37 +0100 |
---|---|---|
committer | Karel Kočí <cynerd@email.cz> | 2016-01-08 16:09:37 +0100 |
commit | 9073bf1ccac68cfaa93d4bbe5c9b1b3fe98fcd8c (patch) | |
tree | b7eaec69cc0417d49f0f785a887d87728f1321b5 /mcwrapper | |
parent | b0ad3b14a12bf3725cfd571036dba7e5664d4f57 (diff) | |
download | mcserver-wrapper-9073bf1ccac68cfaa93d4bbe5c9b1b3fe98fcd8c.tar.gz mcserver-wrapper-9073bf1ccac68cfaa93d4bbe5c9b1b3fe98fcd8c.tar.bz2 mcserver-wrapper-9073bf1ccac68cfaa93d4bbe5c9b1b3fe98fcd8c.zip |
Change documentation and add configfile argument
Configuration options are from previous commit documented directly in
example configuration file. So they don't have to be documented in
readme.
New argument configfile was added because if user uses default paths
for configuration files, it can be sometime unclear what file was used.
This prints path to used file.
Also as small feature, if no identifier is specified as argument neither
in configuration file help text is printed.
Diffstat (limited to 'mcwrapper')
-rwxr-xr-x | mcwrapper | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -324,16 +324,26 @@ def print_help(): print(' Decrease verbose level of output.') print(' --config CONFIG_FILE') print(' Specify configuration file to be used.') + print(' --configfile') + print(' prints used configuration file and exits.') print(' IDENTIFIER') print(' Identifier for new server. This allows multiple servers running with this') print(' wrapper. Identifier is word without spaces and preferably without special') print(' characters.') sys.exit(_EC_OK) +def print_conffile(): + if '__file__' in vars(conf): + print(conf.__file__) + else: + print("No configuration file used.") + sys.exit(_EC_OK) + if __name__ == '__main__': identifier = None use_config = None verbose_level = 0 + print_config_file = False i = 1 while i < len(sys.argv): arg = sys.argv[i] @@ -353,6 +363,8 @@ if __name__ == '__main__': else: use_config = sys.argv[i] i += 1 + elif arg == '--configfile': + print_config_file = True continue else: for l in arg[1:]: @@ -372,10 +384,16 @@ if __name__ == '__main__': # Parsing args ends load_conf(use_config) + + if print_config_file: + print_conffile() + conf.verbose_level += verbose_level # Set identifier if provided if identifier: conf.identifier = identifier + elif not "identifier" in vars(conf): + print_help() signal.signal(signal.SIGTERM, __signal_term__) signal.signal(signal.SIGINT, __signal_term__) |