Skip to content

Feature request: Ability for west grep to output relative or absolute paths #714

@jhedberg

Description

@jhedberg

Currently, west grep groups the output per-module, having a "header" line for each module and then results relative to that module's root directory. This may be fine for manual/human processing of the output, but it makes it more difficult to integrate it with an editor (to automatically be able to jump to the file/line in question) or even for a human to just copy-paste the full file location to the command line.

Current output:

❯ west grep lfs_format
=== manifest (zephyr):
subsys/fs/littlefs_fs.c:			ret = lfs_format(&fs->lfs, &fs->cfg);
subsys/fs/littlefs_fs.c:	ret = lfs_format(&fs->lfs, &fs->cfg);
=== littlefs (modules/fs/littlefs):
README.md:        lfs_format(&lfs, &cfg);
benches/bench_dir.toml:    lfs_format(&lfs, cfg) => 0;

Desired output:

❯ west topdir
/Users/johedber/src/zephyr
❯ pwd
/Users/johedber/src/zephyr/zephyr
❯ west grep --relative lfs_format
subsys/fs/littlefs_fs.c:			ret = lfs_format(&fs->lfs, &fs->cfg);
subsys/fs/littlefs_fs.c:	ret = lfs_format(&fs->lfs, &fs->cfg);
../modules/fs/littlefs/README.md:        lfs_format(&lfs, &cfg);
../modules/fs/littlefs/benches/bench_dir.toml:    lfs_format(&lfs, cfg) => 0;

Alternative (or in addition to the above):

❯ west topdir
/Users/johedber/src/zephyr
❯ pwd
/Users/johedber/src/zephyr/zephyr
❯ west grep --absolute lfs_format
/Users/johedber/src/zephyr/zephyr/subsys/fs/littlefs_fs.c:			ret = lfs_format(&fs->lfs, &fs->cfg);
/Users/johedber/src/zephyr/zephyr/subsys/fs/littlefs_fs.c:	ret = lfs_format(&fs->lfs, &fs->cfg);
/Users/johedber/src/zephyr/modules/fs/littlefs/README.md:        lfs_format(&lfs, &cfg);
/Users/johedber/src/zephyr/modules/fs/littlefs/benches/bench_dir.toml:    lfs_format(&lfs, cfg) => 0;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions