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 command: config #133

Open
26 tasks
drpaneas opened this issue Nov 1, 2020 · 0 comments
Open
26 tasks

Add command: config #133

drpaneas opened this issue Nov 1, 2020 · 0 comments
Milestone

Comments

@drpaneas
Copy link
Collaborator

drpaneas commented Nov 1, 2020

Scenario
The first thing a user should do immediately after installing romie, would be to initialize the configuration file. This file's location is the only one that cannot be changed. The configuration file will always be: ~/.romie/romie.conf. Inside this configuration file, there will be various things to tweak, such as the database file location, and others. Every single entry in that configuration file should be able to be edited in two ways:

  1. Manually editing the file using a text editor
  2. Using romie itself: for example, romie config set <option>

In this task, we will focus on the second approach, where the user would be able to modify the setting of romie, using romie., where each option would be a sub-command of config. As for the first option, we need to make sure the user hasn't damaged the file by inserting wrong configuration, syntax, or typos. To do that, we will introduce a check for the configuration using a sub-command check.

User Stories

  • Given you start using romie for the very first time, when you initialize the configuration file romie config init, then the configuration will be created under a default location in your system.
  • Given you have already initialized the configuration, when you type romie config, then you will the contents of the file.
  • Given you have already initialized the configuration, when you type romie config view db, then you will parse the configuration file and print it's db setting value.
  • Given you have already initialized the configuration, when you type romie config check, it will return OK if everything is seems healthy.
  • Given you have already initialized the configuration, when you type romie config clean, it will delete the configuration file. If you pass the --all flag it will also delete any other file (e.g. the database file).
  • Given you have modified the configuration of the db file, when you type romie config reset db it will move it to the default location.

Acceptance Criteria

  • Use the Cobra framework to create a romie config, romie config init, romie config check, romie config set db, and romie config view db.
  • Every command should come with their appropriate help
  • Write a functional test in the CI

For romie config check

  • Write a function that checks the configuration has been successfully created and if not return an error
  • Write a function that checks the configuration file is not damaged (e.g. Viper can read it)
  • Write a function that checks if romie can write and read the file
  • Write a unit test
  • Write a functional test

For romie config init

  • Create the configuration file at ~/.romie/romie.conf and populate it with default values, such set the db setting into ~/.romie/db.json.
  • Read a configuration file that will have a default location of the database file and create that file
  • If the configuration file already exists, return doing nothing, informing the user that romie has already been initialized.
  • Return any errors if there are any
  • Write unit tests
  • Write functional test in the CI

For romie config set db $arg

  • Write the path given as $arg into the value of the db setting into the configuration file.
  • Write a unit test
  • Write a functional test in the CI

For romie config clear

  • Removes the configuration file if any
  • Passing the --all flag will delete any other file that is listed in the configuration file (e.g. the db file)

For romie config reset db

  • Move the db file to the default location (~/.romie/db.json`)
  • Write functional test in the CI

For romie config view db

  • Returns the value of the db option into the configuration file
  • Write a unit test for return the content, making sure this is a db setting
  • Write a functional test in the CI

For romie config

  • Prints the contents of the configuration file
  • Write a functional test in the CI

Hints

@drpaneas drpaneas added this to the CLI milestone Nov 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant