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

Fix configuration use in start command #87

Merged
merged 2 commits into from
Dec 11, 2024
Merged

Conversation

shantanuraj
Copy link
Member

What does this PR do?

  • Start command should work even if config doesn't exist

    let config_path = config::locate::locate_config_path()?;
    let track_config = config::parser::get_config_from_file(config_path)?;
    let default_time_entry = track_config.get_default_entry(entities.clone())?;

    These established a hard dependency on the config infrastructure.
    We fix this, by only following the config code branch if a configuration
    path can be located.

    Caveat: This silences the error if a configuration is found but cannot
    be parsed. I'm treading on the side of simplicity over correctness here.
    In future we might treat the configuration error as a critical error.

  • Simplify default config file
    Previously our default config for toggl config --init enforced
    the use of git.
    Such that, even for non-vcs tracked paths we would use a configuration
    that tries to resolve it's values from git which errors out.

    I think in general the wildcard match rule [*] should be agnostic of vcs.

    This changes the default to use {{current_dir}} which is guarenteed
    to work at any path the toggl command is invoked as is a much better
    default.

Note: This is my configuration block for the wildcard match.

['*']
tags = ["{{current_dir}}"]
billable = true

Context

Closes #84

```rust
let config_path = config::locate::locate_config_path()?;
let track_config = config::parser::get_config_from_file(config_path)?;
let default_time_entry = track_config.get_default_entry(entities.clone())?;
```

These established a hard dependency on the `config` infrastructure.
We fix this, by only following the config code branch if a configuration
path can be located.

Caveat: This silences the error if a configuration is found but cannot
be parsed. I'm treading on the side of simplicity over correctness here.
In future we might treat the configuration error as a critical error.

Closes #84
- Previously our default config for `toggl config --init` enforced
  the use of git.
  Such that, even for non-vcs tracked paths we would use a configuration
  that tries to resolve it's values from `git` which errors out.
- I think in general the wildcard match rule `[*]` should be agnostic
  of vcs.
- This changes the default to use `{{current_dir}}` which is guarenteed
  to work at any path the `toggl` command is invoked as is a much better
  default.

Note: This is my configuration block for the wildcard match.

```toml
['*']
tags = ["{{current_dir}}"]
billable = true
```

Context: #84
@shantanuraj shantanuraj self-assigned this Dec 11, 2024
@shantanuraj shantanuraj merged commit e8dde57 into main Dec 11, 2024
5 checks passed
@shantanuraj shantanuraj deleted the shantanu/config-fixes branch December 11, 2024 16:18
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.

Warning when outside of git directory
1 participant