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 user configuration #225

Merged
merged 15 commits into from
Nov 7, 2022
Merged

Add user configuration #225

merged 15 commits into from
Nov 7, 2022

Conversation

Nusiq
Copy link
Member

@Nusiq Nusiq commented Nov 2, 2022

First commit added basic user_config reader:

  • project.app_data_storage - replaces the useAppData property form the config.json file
  • user.name - replaces the name property in config file created by 'regolith init'
  • resolvers - is a list of URLs to 'resolver.json' files. This property is only partially implemented. Currently it only uses the first item from the list or the default value if the 'config.toml' doesn't specify any.

- project.app_data_storage - replaces the useAppData property form the config.json file
- user.name - replaces the name properti in config file created by 'regolith init'
- resolvers - is a list of URLs to 'resolver.json' files. This property is only
  partially implemented. Currently it only uses the first item from the list or
  the default value if the 'config.toml' doesn't specify any.
@Nusiq Nusiq changed the title Added basic user_config reader Add user cofniguration Nov 2, 2022
@Nusiq Nusiq changed the title Add user cofniguration Add user configuration Nov 2, 2022
@Nusiq
Copy link
Member Author

Nusiq commented Nov 5, 2022

OUTDATED !!!

I think the help message is a nice summary of what the config command currently does:

The config command is used to manage the user configuration of Regolith. It can access and modify
global and project-specific configuration files. The global configuration file is stored in the
application data folder in the "user_config.json" file. The project-specific configuration file is
stored in the ".regolith/user_config.json". The project specific configuration file is used when
the local doesn't have specific properties defined. If the global configuration doesn't define them
either, the default values are used.

The behavior of the command changes based on the used flags and the number of provided arguments.
The cheetsheet below shows the possible combinations of flags and arguments and what they do:

Printing all properties:                        regolith config
Printing specified property:                    regolith config <key>
Setting property value:                         regolith config <key> <value>
Deleting a property:                            regolith config <key> --delete
Appending to a list proeprty:                   regolith config <key> <value> --append
Replacing item in a list property:              regolith config <key> <value> --index <index>
Deleting item in a list property:               regolith config <key> --index <index> --delete

You can use the "--global" or "--local" flags for all of the above combinations. To change whether
the command uses the global or local (project-specific) configuration file.

If you skip the "--global" or "--local" flag:
-  The commands that edit the config file use the local config file by default.
-  The commands that print the config file will print a combined view of the local and global
   configuration. This view defines, what Regolith will actually use when running the project.

You can use "regolith config" command to see the full configuration to learn what properties are
available.

muzzammil.xyz/jsonc v1.0.0
)

replace github.com/hashicorp/go-getter => github.com/arikkfir/go-getter v1.6.3-0.20220803164326-281b7670b734
Copy link
Member Author

Choose a reason for hiding this comment

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

We're using the unofficial version of go-getter here. We have to wait until this PR will be merged:

@Nusiq
Copy link
Member Author

Nusiq commented Nov 6, 2022

I removed the --local flag and the option of saving the user config locally. It didn't make much sense to save user config in the .regolith path.

The config command is used to manage the user configuration of Regolith. It can access and modify
the user configuration file. The data is stored in the application data folder in the
"user_config.json" file.

The behavior of the command changes based on the used flags and the number of provided arguments.
The cheetsheet below shows the possible combinations of flags and arguments and what they do:

Printing all properties:                        regolith config
Printing specified property:                    regolith config <key>
Setting property value:                         regolith config <key> <value>
Deleting a property:                            regolith config <key> --delete
Appending to a list proeprty:                   regolith config <key> <value> --append
Replacing item in a list property:              regolith config <key> <value> --index <index>
Deleting item in a list property:               regolith config <key> --index <index> --delete

The printing commands can take the --full flag to print configuration with the default values
included (if they're not defined in the config file). Without the flag, the undefined properties
will be printed as null or empty list.

Usage:
  regolith config [key] [value] [flags]

Flags:
  -a, --append      Append value to array property
      --debug       Enables debugging
  -d, --delete      Delete property
  -f, --full        When printing, prints the full configuration including default values.
  -h, --help        help for config
  -i, --index int   The index of the array property on which to act (default -1)

@Nusiq Nusiq marked this pull request as ready for review November 6, 2022 11:20
@Nusiq
Copy link
Member Author

Nusiq commented Nov 6, 2022

This PR closes #221

@Nusiq Nusiq merged commit d0eaab7 into develop Nov 7, 2022
@Nusiq Nusiq deleted the user-config branch November 7, 2022 22:03
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

Successfully merging this pull request may close these issues.

2 participants