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

No prompts flag for non interactive environments. #1913

Merged
merged 8 commits into from
Mar 13, 2019

Conversation

afinch7
Copy link
Contributor

@afinch7 afinch7 commented Mar 12, 2019

Fixes #1580

@hayd
Copy link
Contributor

hayd commented Mar 12, 2019

Does atty not already do this?

if !atty::is(atty::Stream::Stdin) || !atty::is(atty::Stream::Stderr) {

@afinch7
Copy link
Contributor Author

afinch7 commented Mar 12, 2019

That only checks if stdio is a tty. Not really the same as the user simply wanting to disable all prompts regardless of tty.

@@ -149,6 +153,7 @@ pub fn set_flags(
opts.optflag("", "allow-env", "Allow environment access");
opts.optflag("", "allow-run", "Allow running subprocesses");
opts.optflag("A", "allow-all", "Allow all permissions");
opts.optflag("", "no-prompt", "Do not use prompts");
Copy link
Member

Choose a reason for hiding this comment

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

--deny ?
#1580

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No prompt shouldn't be limited to permissions, so in that respect it's different than --deny. Either your there to answer for prompts or you aren't as a user.

Copy link
Contributor

Choose a reason for hiding this comment

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

What other prompts are there?

I don't understand the difference.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess for the time being it only affects permissions, but If we add any other prompts in the future it should be used to allow disabling those as well.

Copy link
Member

@ry ry Mar 12, 2019

Choose a reason for hiding this comment

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

--deny would be confusing when combined with, say, --allow-read

> deno  foo.ts --allow-read --deny

What is intended is: "run deno with foo.ts as the main script, allow fs read access, but do not prompt for permission"
But people might interpret this as: "run deno with foo.ts as the main script, allow fs read access, deny all access (overriding previous?)"

Copy link
Member

Choose a reason for hiding this comment

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

--no-prompt is kinda long.... Can we quickly just throw out a few other suggestions?

Copy link
Member

Choose a reason for hiding this comment

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

No other suggestions it seems. I can't think of anything better...

Copy link
Contributor

Choose a reason for hiding this comment

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

what about --no (as analogous to --yes e.g. of unix tools)

}
r
} else {
Err(permission_denied())
Copy link
Member

Choose a reason for hiding this comment

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

Seems like there are 4 very similar sections of code here. Is it possible to "DRY" this up?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That should be much cleaner.

Copy link
Member

@ry ry left a comment

Choose a reason for hiding this comment

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

This looks well implemented to me. I think --no-prompts is a fine name.

My only hesitation is that there aren't any tests... I realize it's a bit tricky to test things like this, but I wonder if you've looked at adapting tools/permission_prompt_test.py ? Is it possible to have some test of this flag using the technique there?

@hayd
Copy link
Contributor

hayd commented Mar 12, 2019

https://github.com/denoland/deno/pull/1591/files has some relevant tests

Edit: I see you got in there already! 👍

Copy link
Member

@ry ry left a comment

Choose a reason for hiding this comment

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

LGTM - thank you for the tests!

Copy link
Member

@ry ry left a comment

Choose a reason for hiding this comment

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

Err- it looks like the tests aren't being called. See line 196 of tools/permission_prompt_test.py

@@ -98,6 +98,7 @@ impl DenoPermissions {
r
}

/// Try to present the user with a permission prompt permission_denied if no_prompts is enabled
Copy link
Member

Choose a reason for hiding this comment

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

Sorry - can you wrap this at 80 cols?

Odd that rustfmt isn’t doing that...

Also this will give us a chance to sample from the appveyor failure distraction again

@ry ry mentioned this pull request Mar 13, 2019
Copy link
Member

@ry ry left a comment

Choose a reason for hiding this comment

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

LGTM - looks like its green now.

I think there are some spurious failures in the appveyor build - but it seems unrelated.

@ry ry merged commit 7e09221 into denoland:master Mar 13, 2019
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

3 participants