Repos / mcross / 558d851534
commit 558d851534c1a3773ce7986a5fa1fa970f99354e
Author: Bùi Thành Nhân <hi@imnhan.com>
Date:   Tue Jun 2 12:02:20 2020 +0700

    move CLI parsing out of controller, bump 0.5.12

diff --git a/README.md b/README.md
index 177e45f..4ba5d9f 100644
--- a/README.md
+++ b/README.md
@@ -29,6 +29,16 @@ # Installation
 Better distribution methods to be explored later.
 Maybe it's finally time to try nuitka?
 
+# Usage
+
+CLI arguments: `--textfont`, `--monofont`
+
+Keyboard shortcuts:
+
+- `Ctrl-l`: jump to address bar.
+- Hold `Alt` to see possible button shortcuts underlined. This is what Qt calls
+  [Accelerator Keys](https://doc.qt.io/qt-5/accelerators.html).
+
 
 # Development
 
diff --git a/pyproject.toml b/pyproject.toml
index 77e2e7a..9910a78 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
 [tool.poetry]
 name = "mcross"
-version = "0.5.11"
+version = "0.5.12"
 description = "Do you remember www?"
 authors = ["nhanb <hi@imnhan.com>"]
 license = "MIT"
diff --git a/src/mcross/__init__.py b/src/mcross/__init__.py
index 41a25c8..200999f 100644
--- a/src/mcross/__init__.py
+++ b/src/mcross/__init__.py
@@ -1,6 +1,16 @@
+import argparse
+
 from .gui.controller import Controller
 
 
 def run():
-    c = Controller()
+
+    # Parse CLI arguments
+    argparser = argparse.ArgumentParser()
+    argparser.add_argument("--textfont")
+    argparser.add_argument("--monofont")
+    args = argparser.parse_args()
+
+    # Actually start the program
+    c = Controller(args)
     c.run()
diff --git a/src/mcross/gui/controller.py b/src/mcross/gui/controller.py
index 0a8fa8a..92d59c7 100644
--- a/src/mcross/gui/controller.py
+++ b/src/mcross/gui/controller.py
@@ -2,7 +2,6 @@
 import threading
 import time
 import traceback
-import argparse
 from ssl import SSLCertVerificationError
 from tkinter import READABLE, Tk, messagebox
 
@@ -20,21 +19,13 @@
 
 statusbar_logger = logging.getLogger("statusbar")
 
-argparser = argparse.ArgumentParser()
-argparser.add_argument("--textfont")
-argparser.add_argument("--monofont")
-args = argparser.parse_args()
 
 class Controller:
-    def __init__(self):
+    def __init__(self, args):
         self.root = Tk()
         self.root.alt_shortcuts = set()
         self.model = Model()
-        self.view = View(
-            self.root,
-            self.model,
-            fonts=(args.textfont, args.monofont)
-        )
+        self.view = View(self.root, self.model, fonts=(args.textfont, args.monofont))
         self.root.title("McRoss Browser")
         self.root.geometry("800x600")