-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #166 from GEOS-ESM/develop
Merge develop into main
- Loading branch information
Showing
27 changed files
with
548 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# This is a skeleton example of a .mepoconfig file | ||
# | ||
# .mepoconfig is a config file a la gitconfig with sections and options. | ||
# | ||
# Currently, .mepoconfig files recognize two sections: [init] and [alias] | ||
# | ||
# ======================================================================= | ||
# | ||
# [init] Section | ||
# | ||
# The init section currently recognizes one option, style. | ||
# This has three allowed values: naked, postfix, prefix | ||
# | ||
# So if you have: | ||
# | ||
# [init] | ||
# style = postfix | ||
# | ||
# This is equivalent to doing: | ||
# | ||
# mepo init --style postfix | ||
# | ||
# or when running with mepo clone: | ||
# | ||
# mepo clone --style postfix | ||
# | ||
# ======================================================================= | ||
# | ||
# [alias] Section | ||
# | ||
# The [alias] Section is used to make aliases of mepo commands. For | ||
# example this: | ||
# | ||
# [alias] | ||
# st = status | ||
# | ||
# lets one run "mepo st" as an alias to "mepo status" | ||
# | ||
# Note: Due to lack of skill of the developer and limitations in Argparse, | ||
# you can only alias mepo primary commands and not "subcommands" or | ||
# "options". So you can have an alias for "commit" and for "branch", | ||
# but you can't do an option for "commit -m" or "branch create". |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import argparse | ||
import textwrap | ||
|
||
class MepoConfigArgParser(object): | ||
|
||
def __init__(self, config): | ||
self.config = config.add_subparsers() | ||
self.config.title = 'mepo config sub-commands' | ||
self.config.dest = 'mepo_config_cmd' | ||
self.config.required = True | ||
self.__get() | ||
self.__set() | ||
self.__delete() | ||
self.__print() | ||
|
||
def __get(self): | ||
get = self.config.add_parser( | ||
'get', | ||
formatter_class=argparse.RawDescriptionHelpFormatter, | ||
description = textwrap.dedent('''\ | ||
Get config <entry> in .mepoconfig. | ||
Note this uses gitconfig style where <entry> is | ||
of the form "section.option" So to get something like: | ||
[alias] | ||
st = status | ||
You would run "mepo config get alias.st" | ||
''')) | ||
get.add_argument( | ||
'entry', | ||
metavar = 'entry', | ||
help = 'Entry to display.') | ||
|
||
def __set(self): | ||
set = self.config.add_parser( | ||
'set', | ||
formatter_class=argparse.RawDescriptionHelpFormatter, | ||
description = textwrap.dedent('''\ | ||
Set config <entry> to <value> in .mepoconfig. | ||
Note this uses gitconfig style where <entry> is | ||
of the form "section.option" So to set something like: | ||
[alias] | ||
st = status | ||
You would run "mepo config set alias.st status" | ||
''')) | ||
set.add_argument( | ||
'entry', | ||
metavar = 'entry', | ||
help = 'Entry to set.') | ||
set.add_argument( | ||
'value', | ||
metavar = 'value', | ||
help = 'Value to set entry to.') | ||
|
||
def __delete(self): | ||
delete = self.config.add_parser( | ||
'delete', | ||
formatter_class=argparse.RawDescriptionHelpFormatter, | ||
description = textwrap.dedent('''\ | ||
Delete config <entry> in .mepoconfig. | ||
Note this uses gitconfig style where <entry> is | ||
of the form "section.option" So to delete something like: | ||
[alias] | ||
st = status | ||
You would run "mepo config delete alias.st" | ||
''')) | ||
delete.add_argument( | ||
'entry', | ||
metavar = 'entry', | ||
help = 'Entry to delete.') | ||
|
||
def __print(self): | ||
print = self.config.add_parser( | ||
'print', | ||
description = 'Print contents of .mepoconfig') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.