Skip to content

Commit 7e49167

Browse files
author
Michael Murray
committed
Merge pull request slack-samples#1 from ClipCard/specify-conf-file
Specify location of clipbot conf file
2 parents a907737 + 6191182 commit 7e49167

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

rtmbot.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import sys
1111
import time
1212
import logging
13+
from argparse import ArgumentParser
1314

1415
from 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+
167180
if __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 = []

0 commit comments

Comments
 (0)