コード例 #1
0
ファイル: App.xaml.cs プロジェクト: reider-roque/Elpis
        public bool HandleCommandLine(IList<string> args)
        {
            CommandLineOptions clo = new CommandLineOptions();
            OptionSet p = new OptionSet()
               .Add("c|config=", "a {CONFIG} file to load ", delegate(string v) { clo.ConfigPath = v; })
               .Add("h|?|help", "show this message and exit", delegate(string v) { clo.ShowHelp = v != null; })
               .Add("playpause", "toggles playback", delegate(string v) { clo.TogglePlayPause = v != null; })
               .Add("next", "skips current track", delegate(string v) { clo.SkipTrack = v != null; })
               .Add("thumbsup", "rates the song as suitable for this station", delegate(string v) { clo.DoThumbsUp = v != null; })
               .Add("thumbsdown", "rates the song as unsuitable for this station", delegate(string v) { clo.DoThumbsDown = v != null; })
               .Add("s|station=", "starts station \"{STATIONNAME}\" - puts quotes around station names with spaces", delegate(string v) { clo.StationToLoad = v; });

            try
            {
                p.Parse(args);
            }
            catch (OptionException e)
            {
                clo.ShowHelp = true;
                Elpis.MainWindow.SetCommandLine(clo);
                ShowHelp(p, e.Message);
            }

            Elpis.MainWindow.SetCommandLine(clo);

            if (clo.ShowHelp)
            {
                ShowHelp(p);
            }
            else
            {
                if (MainWindow != null)
                {
                    ((Elpis.MainWindow)MainWindow).DoCommandLine();
                }
            }

            return true;
        }
コード例 #2
0
ファイル: MainWindow.xaml.cs プロジェクト: CristaliS/Elpis
 public static void SetCommandLine(CommandLineOptions clo)
 {
     _clo = clo;
 }