Skip to content

Open a file at path and line from the command line #317

Description

@jongio

Let grut accept a file path, optionally with a line number, so you can jump straight into a file. Today grut [dir] only takes a directory. Accepting a file makes grut usable as the target of shell pipelines and quick jumps like grut internal/git/client.go:120.

Solution

When the positional argument points at a file, open grut rooted at the file's directory, select that file in the File Tree, focus the Preview panel, and scroll to the line when a :line suffix is present. Keep the existing directory behavior unchanged.

Acceptance criteria

  • grut path/to/file opens with that file selected and shown in the Preview panel.
  • grut path/to/file:42 additionally scrolls the preview to line 42.
  • A trailing :line on a path that does not exist is treated as part of the directory argument, matching current behavior.
  • Passing a directory continues to work exactly as before.
  • Unit tests cover the file-vs-directory argument parsing and the :line suffix handling.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestideaFeature idea from the idea pipeline

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions