Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to specify a custom configuration file #1143

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions mackup/mackup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ class Mackup(object):

"""Main Mackup class."""

def __init__(self):
def __init__(self, filename=None):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you assert that the filename parameter is valid? e.g. https://github.com/lra/mackup/blob/master/mackup/config.py#L40

"""Mackup Constructor."""
self._config = config.Config()
self._config = config.Config(filename)

self.mackup_folder = self._config.fullpath
self.temp_folder = tempfile.mkdtemp(prefix="mackup_tmp_")
Expand Down
13 changes: 7 additions & 6 deletions mackup/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
mackup --version

Options:
-h --help Show this screen.
-f --force Force every question asked to be answered with "Yes".
-n --dry-run Show steps without executing.
-v --verbose Show additional details.
--version Show version.
-h --help Show this screen.
-c FILE --config=FILE Configuration file to use.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we go down this road, I guess we could leverage docopt to set a default file in the docstring, e.g. https://github.com/docopt/docopt#help-message-format

-f --force Force every question asked to be answered with "Yes".
-n --dry-run Show steps without executing.
-v --verbose Show additional details.
--version Show version.

Modes of action:
1. list: display a list of all supported applications.
Expand Down Expand Up @@ -61,7 +62,7 @@ def main():
# Get the command line arg
args = docopt(__doc__, version="Mackup {}".format(VERSION))

mckp = Mackup()
mckp = Mackup(args['--config'])
app_db = ApplicationsDatabase()

def printAppHeader(app_name):
Expand Down