Add Prompt #3535
Replies: 14 comments
-
Could be very useful for scenarios as the one you mention! |
Beta Was this translation helpful? Give feedback.
-
@ChrisMissal @patriksvensson NuGetPush(packagePath, new NuGetPushSettings {
ApiKey = Prompt("Enter api key for NuGetPush:")
}); So if we ignore all the fancy stuff gulp-prompt can do for the moment this would be a very simple API with just a single method: string Prompt(string message) Some thoughts about the implementation:
|
Beta Was this translation helpful? Give feedback.
-
I see little use for adding the Since you know that the user runs in interactive mode (otherwise you should not display an prompt), you could use the if(Environment.UserInteractive)
{
Console.WriteLine("What is you name?");
var name = Console.ReadLine();
} |
Beta Was this translation helpful? Give feedback.
-
That said, A new property |
Beta Was this translation helpful? Give feedback.
-
I'm not against adding |
Beta Was this translation helpful? Give feedback.
-
@devlead What do you think about this? |
Beta Was this translation helpful? Give feedback.
-
Throwing if not running in user interactive mode sounds very reasonable 👍 |
Beta Was this translation helpful? Give feedback.
-
I'm on the fence, can see the use case presented, for fallback scenarios i.e. environment variable / argument missing and some other scenarios. But impotent as stated that it fails if it runs in any server triggered/scheduled scenario. |
Beta Was this translation helpful? Give feedback.
-
I agree. Maybe this is better suited as an addin. |
Beta Was this translation helpful? Give feedback.
-
Well it could definitely start as such. |
Beta Was this translation helpful? Give feedback.
-
Exactly!
👍 |
Beta Was this translation helpful? Give feedback.
-
I've just added a very basic implementation: https://github.com/yvschmid/Cake.Prompt This will prevent it from throwing:
@patriksvensson Should we still add the |
Beta Was this translation helpful? Give feedback.
-
Prompting seems to be used for secrets -- why not do something specific for secrets? I'm thinking of the following:
PromptOrDecryptAesSecret() would look in a folder called ".cake.secrets" for the file "db_password.aes". If not found, it'd prompt and then save the secret in db_password.aes for later. You probably could use async/await to detect if you're in a non-interactive session -- if there is no activity for 30 seconds, throw an exception. |
Beta Was this translation helpful? Give feedback.
-
This is what I did if anyone else is interested. It works like I described above. You can put your password in a password manager and then run the following after opening a powershell prompt:
Below is the cake code:
|
Beta Was this translation helpful? Give feedback.
-
Sometimes I'll have tasks in my builds that are run manually. These may occasionally require data that I don't want to commit. One example would be publishing to NuGet, but in doing so, prompts for an API key.
An example in gulp: https://www.npmjs.com/package/gulp-prompt
Beta Was this translation helpful? Give feedback.
All reactions