Skip to content

Make devlog init idempotent and create the full data directory structure #10

Description

@gustmrg

Improve devlog init so it is safe to run multiple times and fully prepares the local DevLog workspace.

Context:

  • README.md says devlog init is safe to run multiple times and will not overwrite existing data
  • Current implementation uses viper.SafeWriteConfig(), which can fail when the config already exists
  • Current implementation creates only the base ~/.devlog/ directory and writes config, but does not ensure subdirectories exist

Expected behavior:

  • devlog init can be run repeatedly without failing in normal already-initialized cases
  • Existing config should not be overwritten
  • Missing directories should be created automatically
  • The command should report what was created versus what already existed
  • Directories that should be ensured:
    • ~/.devlog/
    • ~/.devlog/entries/
    • ~/.devlog/summaries/
    • ~/.devlog/templates/

Implementation notes:

  • Preserve existing user config if config.json is already present
  • Create config only when it does not already exist
  • If some directories are missing, create only the missing ones
  • Return real errors only for actual failure cases such as permission issues or invalid paths
  • Consider printing a friendly summary such as:
    • config already exists
    • created entries/
    • created summaries/

Acceptance criteria:

  • Running devlog init on a fresh machine creates config and required directories
  • Running devlog init again succeeds without overwriting existing config
  • If one or more subdirectories are missing, they are recreated
  • The command output clearly indicates what happened
  • Behavior matches the README claim that init is safe to run multiple times

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions