Invocation changed
-t/--test run test -c/--config specify config file
This commit is contained in:
parent
c86ab5e3ab
commit
42ab76dd3a
@ -1,11 +1,12 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
import argparse
|
||||
|
||||
from .core import Status
|
||||
from .core.modules import Module, IntervalModule
|
||||
from .core.settings import SettingsBase
|
||||
from .core.config import Config
|
||||
from i3pystatus.core import Status
|
||||
from i3pystatus.core.modules import Module, IntervalModule
|
||||
from i3pystatus.core.settings import SettingsBase
|
||||
from i3pystatus.core.config import Config
|
||||
|
||||
__all__ = [
|
||||
"SettingsBase",
|
||||
@ -14,8 +15,13 @@ __all__ = [
|
||||
]
|
||||
|
||||
def main():
|
||||
config = Config()
|
||||
if len(sys.argv) == 2 and sys.argv[1] == "test":
|
||||
parser = argparse.ArgumentParser(description='A replacement for i3status')
|
||||
parser.add_argument("-c", "--config", action="store", help="Config file")
|
||||
parser.add_argument("-t", "--test", action="store_true", help="Test modules")
|
||||
args = parser.parse_args()
|
||||
|
||||
config = Config(config_file=args.config)
|
||||
if args.test:
|
||||
config.test()
|
||||
else:
|
||||
config.run()
|
||||
|
@ -39,9 +39,9 @@ class ConfigFinder:
|
||||
raise RuntimeError("Didn't find a config file, tried\n * {mods}".format(mods="\n * ".join(failed)))
|
||||
|
||||
class Config:
|
||||
def __init__(self):
|
||||
def __init__(self, config_file=None):
|
||||
self.finder = ConfigFinder()
|
||||
self.config_file = self.finder.find_config_file()
|
||||
self.config_file = config_file or self.finder.find_config_file()
|
||||
|
||||
def run(self):
|
||||
runpy.run_path(self.config_file, run_name="i3pystatus._config")
|
||||
|
@ -30,6 +30,9 @@ class Module(SettingsBase):
|
||||
"""
|
||||
return True
|
||||
|
||||
def run(self):
|
||||
pass
|
||||
|
||||
def on_click(self, button):
|
||||
if button == 1: # Left mouse button
|
||||
self.on_leftclick()
|
||||
|
Loading…
Reference in New Issue
Block a user