Home General

Get run values at start from the user

edited February 19 in General

Hi, maybe someone has made a clever solution for this.
I have A LOT of everyday-scripts that do things and many of then have a few configuration rows at the top and I need to uncomment the one needed for this specific run. Most common is "what environment would you like to use: dev, stg, acc, prd".
Is there a way to have some kind of GUI for this, when I press RUN I would like a small dialog to show up that let me select a predefined value. Or something in linqpad itself, like when you select the Data-connection from the combo.

The two solutions I've come up with is
1. Use "Util.ReadLine" and then the user writes "dev"
2. I'm on windows so I've tried just to make a simple Windows form to show with buttons, one button for every environment... and yes... it works.. but it feels trashy and also it is very slow, not sure what is going on there, the first run takes a few seconds to load the form stuff... I guess.

Would be super nice to have like just a simple
var env = Util.GetComboChoice("what evironment?", "dev,sys,stg,prd")

Anyone has any ideas how to collect configuration values from the user?
:-)

Comments

  • var env = Util.ReadLine("what evironment?", "dev", new string[] { "dev", "sys", "stg", "prd" });
    

    You can even use Util.SaveString and Util.LoadString if you want to remember the users preference.

    Alternatively the LinqPad controls (like LINQPad.Controls.DataListBox) would be much faster to startup and integrate better into the LinqPad UI.

  • edited February 19
    #define DEV
    //#define PROD
    
    #if DEV
    var _defineGuard = 1;
    // Dev config here
    #endif
    
    #if PROD
    var _defineGuard = 1;
    // Prod config here
    #endif
    
  • Ctrl+F1 and search for readline as @sgmoore suggested.

    However, it allows user to type value not in list.

Sign In or Register to comment.