Skip to content

Explain config loading behavior in help text #540

@erdii

Description

@erdii

Hey :)

I was confused by how ocm-cli selects its config files (and documents other behavior) and dug around a little :

How ocm-cli selects a config file path

Because config.Location() initially defaults to ~/.ocm.json but then stats the file to see if it exists and when it does not, the location is then actually defaulted to ~/.config/ocm/ocm.json (or wherever the user config folder on your system lives).

The config location is selected in this order:

  • checking $OCM_CONFIG. If not empty it will be the config location.
  • checking ~/.ocm.json. If a file exists there it will the the config location.
  • falling back to $XDG_CONFIG_HOME/ocm/ocm.json (XDG_CONFIG_HOME is ~/.config by default)

I think the description for ocm config should be updated to properly reflect this behavior.
ocm config --help currently states

The location of the configuration file is gleaned from the 'OCM_CONFIG' environment variable,
or ~/.ocm.json if that variable is unset. Currently using: /home/erdii/.config/ocm/ocm.json

Which is not the complete truth.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions