예제 #1
0
파일: getbin.cs 프로젝트: jacksonh/getbin
    public static int Main(string [] args)
    {
        Driver driver = new Driver ();
        bool help = false;

        var p = new OptionSet () {
                { "h|?|help", v => help = v != null },
                { "pb|pastbin-url", v => driver.PasteBinUrl = v },
                { "r|redirect-stdout", v => driver.RedirectToStdout = v != null },
                { "o|overwrite-existing", v => driver.OverwriteExisting = v != null },
                { "v|verbose", v => driver.Verbose =  v != null },
        };

        List<string> extra = null;
        try {
            extra = p.Parse (args);
        } catch (OptionException){
            Console.WriteLine ("Try `getbin --help' for more information.");
            return 1;
        }

        if (help){
            ShowHelp (p);
            return 0;
        }

        if (extra.Count < 1) {
            ShowHelp (p);
            return -1;
        }

        if (extra.Count > 1)
            driver.FileName = extra [1];
        driver.Url = extra [0];

        driver.GetBin ();
        return 0;
    }