File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change 1010import sys
1111import time
1212import logging
13+ from argparse import ArgumentParser
1314
1415from slackclient import SlackClient
1516
@@ -164,14 +165,27 @@ def main_loop():
164165 except :
165166 logging .exception ('OOPS' )
166167
168+
169+ def parse_args ():
170+ parser = ArgumentParser ()
171+ parser .add_argument (
172+ '-c' ,
173+ '--config' ,
174+ help = 'Full path to config file.' ,
175+ metavar = 'path'
176+ )
177+ return parser .parse_args ()
178+
179+
167180if __name__ == "__main__" :
181+ args = parse_args ()
168182 directory = os .path .dirname (sys .argv [0 ])
169183 if not directory .startswith ('/' ):
170184 directory = os .path .abspath ("{}/{}" .format (os .getcwd (),
171185 directory
172186 ))
173187
174- config = yaml .load (file ('rtmbot.conf' , 'r' ))
188+ config = yaml .load (file (args . config or 'rtmbot.conf' , 'r' ))
175189 debug = config ["DEBUG" ]
176190 bot = RtmBot (config ["SLACK_TOKEN" ])
177191 site_plugins = []
You can’t perform that action at this time.
0 commit comments