rust-cli / rust-cli/config-rs

Introduce an option for disabling the automatic resolver in FileSourceFile

Open
#132 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
3.2k
Forks
265
Avg merge
2h 42m
Merged PRs (30d)
4

Description

If someone needs to import a specific file, excluding the resolve process, with the actual structure is impossible.

Example:
The config file in the folder is called "config.toml" but the user asks for the file "config.ayeye". If I'm building the File with new or with_name, especially with new where you tell the FileFormat, the resolver in /src/file/source/file.rs line 37 if the file not exist search anyway other files with the same basename but one of the valid acceptable extension, reading the configuration from "config.toml" even if there was an error in the name.

That characteristic I'm sure is intended as a feature but in some peculiar case it can produce some very boring error, and only because the resolver cannot be disabled.

I'm proposing three solutions:

  1. Introduce a new FileSource named FileSourceExactFile and a new method in File named with_exact_name(&str, FileFormat) where the resolver is disabled. (I don't really like it as a solution)
  2. Add a flag to the FileSourceFile struct named use_resolver and modify the signature of new and/or with_name. (Breaking change is a big negative point)
  3. Add a flag to the FileSourceFile struct named use_resolver and add a method in File<FileSourceFile> similar to required(bool) where the user can enable or disable the resolver in FileSourceFile (The best solution. No breaking change, no removing of feature, only adding an option flag that if not used will be set to True for retro compatibility)

I'm building the solution 3 for my project, if it is accepted as a good idea, when ready I will send a Pull Request.

Opinion? Question? Observation?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in /src/file/source/file.rs at line 37 and trace how FileSourceFile resolves alternate extensions when the requested file is absent. Review the existing File constructors and required(bool)-style APIs, then define tests that verify the resolver remains enabled by default and can be disabled for an exact filename.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.