Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(mix): add options for mix run #1078

Merged
merged 7 commits into from Mar 30, 2022
Merged

Conversation

Darth-Knoppix
Copy link
Contributor

@Darth-Knoppix Darth-Knoppix commented Mar 29, 2022

What kind of change does this PR introduce?
Improve option suggestions for the mix run command based off Mix run documentation.

What is the current behavior?

Fig does not suggest any options for the mix run command.

What is the new behavior?

Fig will suggest options like:

  • mix run --no-halt
  • mix run --no-deps-check

Additional info:

@Darth-Knoppix Darth-Knoppix changed the title feat: add args for mix run feat: add options for mix run Mar 29, 2022
@withfig-bot
Copy link
Collaborator

Overview

src/mix.ts:

Info:

Single Scripts:

  • mix help
  • mix help

@withfig-bot
Copy link
Collaborator

Hello @Darth-Knoppix,
thank you very much for creating a Pull Request!
Here is a small checklist to get this PR merged as quickly as possible:

  • Do all subcommands / options which take arguments include the args property (args: {})?
  • Are all options modular? E.g. -a -u -x instead of -aux
  • Have all other checks passed?

Please add a 👍 as a reaction to this comment to show that you read this.

src/mix.ts Show resolved Hide resolved
src/mix.ts Show resolved Hide resolved
src/mix.ts Outdated
Comment on lines 83 to 120
{
name: "--preload-modules",
description: "Preloads all modules defined in applications",
args: {},
},
{
name: "--no-compile",
description: "Does not compile even if files require compilation",
args: {},
},
{
name: "--no-deps-check",
description: "Does not check dependencies",
args: {},
},
{
name: "--no-archives-check",
description: "Does not check archives",
args: {},
},
{
name: "--no-halt",
description: "Does not halt the system after running the command",
args: {},
},
{
name: "--no-mix-exs",
description: "Allows the command to run even if there is no mix.exs",
args: {},
},
{
name: "--no-start",
description: "Does not start applications after compilation",
args: {},
},
{
name: "--no-elixir-version-check",
description: "Does not check the Elixir version from mix.exs",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure these accept an argument?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, this was a misunderstanding. Fixing now 👍

src/mix.ts Outdated Show resolved Hide resolved
src/mix.ts Outdated Show resolved Hide resolved
@Darth-Knoppix
Copy link
Contributor Author

Thanks for the tips and great feedback @fedeci!

I used the filepaths template but added a custom filterTemplateSuggestions to bump up the priority for script files (.exs) as they are the most likely to be run too.

src/mix.ts Outdated
Comment on lines 179 to 188
function generatePreferredFilepaths(): Fig.Generator {
return {
template: "filepaths",
filterTemplateSuggestions: (paths) =>
paths.map((path) =>
path.name.endsWith(".exs") ? { ...path, priority: 75 } : path
),
};
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't need to be a function - it can just be a constant.

Suggested change
function generatePreferredFilepaths(): Fig.Generator {
return {
template: "filepaths",
filterTemplateSuggestions: (paths) =>
paths.map((path) =>
path.name.endsWith(".exs") ? { ...path, priority: 75 } : path
),
};
}
const preferredFilepaths: Fig.Generator = {
template: "filepaths",
filterTemplateSuggestions: (paths) =>
paths.map((path) =>
path.name.endsWith(".exs") ? { ...path, priority: 75 } : path
),
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be also simplified with the @fig/autocomplete-generators package!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I didn't see this either 🤦. I've simplified it based on what's in the elixir autocomplete using @fig/autocomplete-generators as suggested 🙏

Darth-Knoppix and others added 2 commits March 30, 2022 14:52
Co-authored-by: Matt Schrage <matthewschrage@gmail.com>
Simplify the generators where .exs files are preferred
Copy link
Contributor

@fedeci fedeci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@fedeci fedeci changed the title feat: add options for mix run feat(mix): add options for mix run Mar 30, 2022
@fedeci fedeci merged commit d13f72d into withfig:master Mar 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants