Skip to content

Mapping of globs to languages #166

@passcod

Description

@passcod

It would be useful to be able to map path globs to supported languages, for cases where tracey's internal list of the extensions doesn't cut it. Motivating examples:

  • extension-less shebanged executables ("scripts"), where bin/foo, bin/bar, bin/baz might all be bash, but will be completely ignored by tracey. In some cases it might be appropriate to rename those to bin/foo.sh or something, but in others it might not. Plus, it doesn't have to be bash: their shebang might be #!/usr/bin/env node or cargo-script...
  • Tool files that need to be at particular filenames but are written in a covered language.
  • Legit extensions for the language that aren't covered by tracey's hardcoded list.

The proposal is for a mapping of globs to language tags (essentially the inverse of "Option B" from #9) which is specified to be "first match wins". Then the internal extension mapping would append to the configured list. For example:

@schema {id crate:tracey-config@1, cli tracey}

specs (
    {
        name example
        include (docs/spec/**/*.md)
        impls (
            {
                name main
                include (
                    installer/**/*.rs
                    admin/**/*.pl
                    bin/*
                )
                language (
                	bin/foobar Perl
                	bin/* Shell
                )
            }
        )
    }
)

Implementation-wise, this would probably involve an enum of supported languages, that is figured from this mapping for each path, and then used throughout; incidentally I've noticed tracey contains at least three different places where it maps extensions to filetypes...

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