Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e8e98ca15a | |||
| 4d1302696e | |||
| 4d78df2cbc | |||
| 4a45081412 | |||
| 9cab9ea610 | |||
| 177fa55bce | |||
| 0783864629 | |||
| 8ec66dd599 |
@@ -249,6 +249,9 @@ class MILC(object):
|
|||||||
"""
|
"""
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""Initialize the MILC object.
|
"""Initialize the MILC object.
|
||||||
|
|
||||||
|
version
|
||||||
|
The version string to associate with your CLI program
|
||||||
"""
|
"""
|
||||||
# Setup a lock for thread safety
|
# Setup a lock for thread safety
|
||||||
self._lock = threading.RLock() if thread else None
|
self._lock = threading.RLock() if thread else None
|
||||||
@@ -263,7 +266,7 @@ class MILC(object):
|
|||||||
self.config = None
|
self.config = None
|
||||||
self.config_file = None
|
self.config_file = None
|
||||||
self.default_arguments = {}
|
self.default_arguments = {}
|
||||||
self.version = os.environ.get('QMK_VERSION', 'unknown')
|
self.version = 'unknown'
|
||||||
self.release_lock()
|
self.release_lock()
|
||||||
|
|
||||||
# Figure out our program name
|
# Figure out our program name
|
||||||
@@ -364,6 +367,7 @@ class MILC(object):
|
|||||||
self.add_argument('--log-file', help='File to write log messages to')
|
self.add_argument('--log-file', help='File to write log messages to')
|
||||||
self.add_argument('--color', action='store_boolean', default=True, help='color in output')
|
self.add_argument('--color', action='store_boolean', default=True, help='color in output')
|
||||||
self.add_argument('--config-file', help='The location for the configuration file')
|
self.add_argument('--config-file', help='The location for the configuration file')
|
||||||
|
self.arg_only.append('config_file')
|
||||||
|
|
||||||
def add_subparsers(self, title='Sub-commands', **kwargs):
|
def add_subparsers(self, title='Sub-commands', **kwargs):
|
||||||
if self._inside_context_manager:
|
if self._inside_context_manager:
|
||||||
@@ -473,8 +477,10 @@ class MILC(object):
|
|||||||
# Coerce values into useful datatypes
|
# Coerce values into useful datatypes
|
||||||
if value.lower() in ['1', 'yes', 'true', 'on']:
|
if value.lower() in ['1', 'yes', 'true', 'on']:
|
||||||
value = True
|
value = True
|
||||||
elif value.lower() in ['0', 'no', 'false', 'none', 'off']:
|
elif value.lower() in ['0', 'no', 'false', 'off']:
|
||||||
value = False
|
value = False
|
||||||
|
elif value.lower() in ['none']:
|
||||||
|
continue
|
||||||
elif value.replace('.', '').isdigit():
|
elif value.replace('.', '').isdigit():
|
||||||
if '.' in value:
|
if '.' in value:
|
||||||
value = Decimal(value)
|
value = Decimal(value)
|
||||||
@@ -495,12 +501,12 @@ class MILC(object):
|
|||||||
|
|
||||||
if argument not in self.arg_only:
|
if argument not in self.arg_only:
|
||||||
# Find the argument's section
|
# Find the argument's section
|
||||||
argument_found = True
|
if argument in self.default_arguments[self._entrypoint.__name__]:
|
||||||
for group in self.default_arguments:
|
argument_found = True
|
||||||
if argument in self.default_arguments[group]:
|
section = self._entrypoint.__name__
|
||||||
argument_found = True
|
if argument in self.default_arguments['general']:
|
||||||
section = group
|
argument_found = True
|
||||||
break
|
section = 'general'
|
||||||
|
|
||||||
if not argument_found:
|
if not argument_found:
|
||||||
raise RuntimeError('Could not find argument in `self.default_arguments`. This should be impossible!')
|
raise RuntimeError('Could not find argument in `self.default_arguments`. This should be impossible!')
|
||||||
@@ -536,7 +542,8 @@ class MILC(object):
|
|||||||
if section_name == 'general':
|
if section_name == 'general':
|
||||||
if option_name in ['config_file']:
|
if option_name in ['config_file']:
|
||||||
continue
|
continue
|
||||||
config.set(section_name, option_name, str(value))
|
if value is not None:
|
||||||
|
config.set(section_name, option_name, str(value))
|
||||||
|
|
||||||
# Write out the config file
|
# Write out the config file
|
||||||
config_dir = self.config_file.parent
|
config_dir = self.config_file.parent
|
||||||
|
|||||||
+1
-1
@@ -1,3 +1,3 @@
|
|||||||
"""A program to help you work with qmk_firmware."""
|
"""A program to help you work with qmk_firmware."""
|
||||||
|
|
||||||
__version__ = '0.0.19'
|
__version__ = '0.0.23'
|
||||||
|
|||||||
@@ -56,7 +56,10 @@ def find_qmk_firmware():
|
|||||||
return Path(milc.cli.config.user.qmk_home).expanduser().resolve()
|
return Path(milc.cli.config.user.qmk_home).expanduser().resolve()
|
||||||
|
|
||||||
if 'QMK_HOME' in os.environ:
|
if 'QMK_HOME' in os.environ:
|
||||||
return Path(os.environ['QMK_HOME']).expanduser().resolve()
|
path = Path(os.environ['QMK_HOME']).expanduser()
|
||||||
|
if path.exists():
|
||||||
|
return path.resolve()
|
||||||
|
return path
|
||||||
|
|
||||||
return Path.home() / 'qmk_firmware'
|
return Path.home() / 'qmk_firmware'
|
||||||
|
|
||||||
@@ -65,6 +68,8 @@ def main():
|
|||||||
"""Setup the environment before dispatching to the entrypoint.
|
"""Setup the environment before dispatching to the entrypoint.
|
||||||
"""
|
"""
|
||||||
# Environment setup
|
# Environment setup
|
||||||
|
import qmk_cli
|
||||||
|
milc.cli.version = qmk_cli.__version__
|
||||||
qmk_firmware = find_qmk_firmware()
|
qmk_firmware = find_qmk_firmware()
|
||||||
os.environ['QMK_HOME'] = str(qmk_firmware)
|
os.environ['QMK_HOME'] = str(qmk_firmware)
|
||||||
os.environ['ORIG_CWD'] = os.getcwd()
|
os.environ['ORIG_CWD'] = os.getcwd()
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
[bumpversion]
|
[bumpversion]
|
||||||
current_version = 0.0.19
|
current_version = 0.0.23
|
||||||
commit = True
|
commit = True
|
||||||
tag = True
|
tag = True
|
||||||
tag_name = {new_version}
|
tag_name = {new_version}
|
||||||
|
|||||||
Reference in New Issue
Block a user