]> git.ipfire.org Git - people/ms/bricklayer.git/commitdiff
Add basic CLI scaffolding
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 5 May 2021 14:48:25 +0000 (14:48 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 5 May 2021 14:48:25 +0000 (14:48 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
src/bricklayer [new file with mode: 0644]
src/python/__init__.py
src/python/i18n.py [new file with mode: 0644]

index 7c5a61d2959f2087f1695127d7e9f5bcf4fb3ec0..77fc6234661f761e4d39572dc581de9bfc57adfc 100644 (file)
@@ -40,5 +40,9 @@ po/POTFILES.in: Makefile
                \! -exec git check-ignore -q {} \; -print | \
                sed -e "s@$(abs_srcdir)/@@g" | LC_ALL=C sort > $@
 
+dist_bin_SCRIPTS = \
+       src/bricklayer
+
 dist_pkgpython_PYTHON = \
-       src/python/__init__.py
+       src/python/__init__.py \
+       src/python/i18n.py
diff --git a/src/bricklayer b/src/bricklayer
new file mode 100644 (file)
index 0000000..e8546b8
--- /dev/null
@@ -0,0 +1,70 @@
+#!/usr/bin/python3
+###############################################################################
+#                                                                             #
+# Bricklayer - An Installer for IPFire                                        #
+# Copyright (C) 2021 IPFire Development Team                                  #
+#                                                                             #
+# This program is free software; you can redistribute it and/or               #
+# modify it under the terms of the GNU General Public License                 #
+# as published by the Free Software Foundation; either version 2              #
+# of the License, or (at your option) any later version.                      #
+#                                                                             #
+# This program is distributed in the hope that it will be useful,             #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of              #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
+# GNU General Public License for more details.                                #
+#                                                                             #
+# You should have received a copy of the GNU General Public License           #
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+###############################################################################
+
+import argparse
+import logging
+import sys
+
+import bricklayer
+
+from bricklayer.i18n import _
+
+# Setup logging
+log = logging.getLogger("bricklayer")
+
+class Cli(object):
+       """
+               This class is called from the command line interface and parses any
+               relevant switches and configures bricklayer.
+       """
+       def parse_cli(self):
+               parser = argparse.ArgumentParser(
+                       description=_("IPFire Installation Tool CLI"),
+               )
+               parser.add_argument("--debug", action="store_true",
+                       help=_("Enable debugging mode"))
+               parser.add_argument("--test", action="store_true",
+                       help=_("Enable test mode (do not perform any actions)"))
+
+               # Parse arguments
+               return parser.parse_args()
+
+       def __call__(self):
+               # Parse command line arguments
+               args = self.parse_cli()
+
+               # Run bricklayer
+               r = self.run_bricklayer(args)
+
+               if r:
+                       sys.exit(r)
+
+       def run_bricklayer(self, args):
+               # Setup bricklayer
+               bl = bricklayer.Bricklayer()
+
+               # Run it
+               return bl()
+
+
+# Main
+c = Cli()
+c()
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..bd0baed1353f83c9f628e9c293a1709c12c3c8d6 100644 (file)
@@ -0,0 +1,29 @@
+###############################################################################
+#                                                                             #
+# Bricklayer - An Installer for IPFire                                        #
+# Copyright (C) 2021 IPFire Development Team                                  #
+#                                                                             #
+# This program is free software; you can redistribute it and/or               #
+# modify it under the terms of the GNU General Public License                 #
+# as published by the Free Software Foundation; either version 2              #
+# of the License, or (at your option) any later version.                      #
+#                                                                             #
+# This program is distributed in the hope that it will be useful,             #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of              #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
+# GNU General Public License for more details.                                #
+#                                                                             #
+# You should have received a copy of the GNU General Public License           #
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+###############################################################################
+
+class Bricklayer(object):
+       """
+               Bricklayer's base class
+       """
+       def __init__(self):
+               pass
+
+       def __call__(self):
+               pass
diff --git a/src/python/i18n.py b/src/python/i18n.py
new file mode 100644 (file)
index 0000000..6716bed
--- /dev/null
@@ -0,0 +1,27 @@
+###############################################################################
+#                                                                             #
+# Bricklayer - An Installer for IPFire                                        #
+# Copyright (C) 2021 IPFire Development Team                                  #
+#                                                                             #
+# This program is free software; you can redistribute it and/or               #
+# modify it under the terms of the GNU General Public License                 #
+# as published by the Free Software Foundation; either version 2              #
+# of the License, or (at your option) any later version.                      #
+#                                                                             #
+# This program is distributed in the hope that it will be useful,             #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of              #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
+# GNU General Public License for more details.                                #
+#                                                                             #
+# You should have received a copy of the GNU General Public License           #
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+###############################################################################
+
+import gettext
+
+def _(singular, plural=None, n=None):
+       if plural:
+               return gettext.dngettext("bricklayer", singular, plural, n)
+
+       return gettext.dgettext("bricklayer", singular)