コード例 #1
0
ファイル: Program.cs プロジェクト: bmd00bmd/tai
        public static void Main(string[] args) {
            
            TaiConfig config = new TaiConfig(@Grapple.GetThisFolder() + "tai.conf");

            //muahahha anonymouse functions in c# !!!
	        var options = new OptionSet() {
                { "iteration-report", "", _ => {SESSION_ACTION = TAI_COMMAND.REPORT;}},
                { "auto-fill-time", "", _ => {SESSION_ACTION = TAI_COMMAND.BURNDOWN;}},
                { "set-story-build", "", _ => {SESSION_ACTION = TAI_COMMAND.SETBUILDID;}},
                { "create-task", "", _ => {SESSION_ACTION = TAI_COMMAND.CREATETASK;}},
                { "?|h|help", "", _ => Echo.HelpText()},
                                
                {"api-url=", "", url => {config["apiUrl"] = url;}}, 
                {"project-id=", "", proj => {config["projectId"] = proj;}},                
                {"target-user="******"", user => {config["targetUser"] = user;}},
                {"story-id=", "", storyId => {config["storyId"] = storyId;}},
                {"build-id=", "", buildId => {config["buildId"] = buildId;}},
                {"burndown-date=", "", date => {config["burndownDate"] = date;}},
                {"email-greeting=", "", hi => {config["emailGreeting"] = hi;}},
                {"email-signature=", "", me => {config["emailSignature"] = me;}},
                {"iteration-number=", "", num => {config["iterationNumber"] = num;}},
                {"status-report-names=", "", names => {config["statusReportNames"] = names;}}, //test these arrays, i will need to serialize them right
                {"task-name=|task-names=", "", names => {config["taskNames"] = names;}}, //test these arrays, i will need to serialize them right

                {"hours-per-day=", "", hours => {config["hoursPerDay"] = hours;}},
                {"v=|verbosity=", "", noise => {Echo.LOG_LEVEL = Convert.ToByte(noise);}},
                {"no-interaction", "", _ => {Grapple.isAllowingHumanInteraction = false;}},

                /* i don't like the idea of passing credentials, however added it for completion */
                {"username="******"", user => {config["username"] = user;}},
                {"password="******"", pass => {config["password"] = pass;}}
			};

            var badInput = options.Parse(args);

            if(badInput.Count > 0) {
                Echo.ErrorReport(badInput.ToArray());
                Echo.OffensiveGesture();
                Echo.HelpText();
            }

            Echo.WelcomeText();

            config = Grapple.TryGetCredentialsManually(config);
            ApiWrapper.Initialize(config);

            TaiTakeCareOfThis[SESSION_ACTION](config);

            Echo.Out("done", 2);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: Wambosa/RallyBot
        public static void Main(string[] args)
        {
            TaiConfig config = new TaiConfig(@Grapple.GetThisFolder() + "tai.conf");

            var options = new OptionSet() {
            { "get-iteration-report", "", _ => {SESSION_ACTION = TAI_COMMAND.GET_ITERATION_REPORT;}},
            { "update-rally-time", "", _ => {SESSION_ACTION = TAI_COMMAND.BURNDOWN;}},
            { "update-story-build", "", _ => {SESSION_ACTION = TAI_COMMAND.UPDATE_STORY_BUILDID;}},
            { "insert-task", "", _ => {SESSION_ACTION = TAI_COMMAND.INSERT_TASK;}},
            { "insert-my-tasks-for-story", "", _ => {SESSION_ACTION = TAI_COMMAND.INSERT_MY_STORY_TASKS;}},
            { "insert-dev-lead-boilerplate", "", _ => {SESSION_ACTION = TAI_COMMAND.INSERT_DEV_LEAD_BOILERPLATE;}},
            { "insert-qa-boilerplate", "", _ => {SESSION_ACTION = TAI_COMMAND.INSERT_QA_BOILERPLATE;}},
            { "get-iteration", "", _ => {SESSION_ACTION = TAI_COMMAND.GET_ITERATION;}},
            { "get-my-storys", "", _ => {SESSION_ACTION = TAI_COMMAND.GET_MY_STORYS;}},
            { "get-my-tasks", "", _ => {SESSION_ACTION = TAI_COMMAND.GET_MY_TASKS;}},
            { "get-team-storys", "", _ => {SESSION_ACTION = TAI_COMMAND.GET_TEAM_STORYS;}},
            { "get-team-story-urls", "", _ => {SESSION_ACTION = TAI_COMMAND.GET_TEAM_STORY_URLS;}},

            { "?|h|help", "", _ => {SESSION_ACTION = TAI_COMMAND.NONE;}},
            {"no-interaction", "", _ => {Grapple.isAllowingHumanInteraction = false;}},

            {"username="******"", user => {config["username"] = user;}},
            {"password="******"", pass => {config["password"] = pass;}},
            {"api-url=", "", url => {config["apiUrl"] = url;}},
            {"project-id=", "", proj => {config["projectId"] = proj;}},
            {"target-user="******"", user => {config["targetUser"] = user;}},
            {"story-id=", "", storyId => {config["storyId"] = storyId;}},
            {"build-id=", "", buildId => {config["buildId"] = buildId;}},
            {"burndown-date=", "", date => {config["burndownDate"] = date;}},
            {"email-greeting=", "", hi => {config["emailGreeting"] = hi;}},
            {"email-signature=", "", me => {config["emailSignature"] = me;}},
            {"iteration-number=", "", num => {config["iterationNumber"] = num;}},
            {"hours-per-day=", "", hours => {config["hoursPerDay"] = hours;}},
            {"description=", "", desc => {config["description"] = desc;}},
            {"note=|notes=", "", note => {config["notes"] = note;}},
            {"block=|blocked=", "", isblock => {config["isBlocked"] = isblock;}},
            {"story-size=", "", size => {config["storySize"] = size;}},
            {"estimate-hours=", "", hours => {config["estimateHours"] = hours;}},
            {"task-state=", "", state => {config["taskState"] = state;}}, /* "Defined", "In-Progress", "Completed" */
            {"task-name=", "", name => {config["taskName"] = name;}},
            {"attachment-type=", "", type => {config["attatchmentType"] = type;}}, //take in the mime-type. type == "base64" indicates that tai does not need to encode it

            {"status-report-names=", "", names => {config["statusReportNames"] = names.Split(',').ToJson();}},
            {"task-names=", "", names => {config["taskNames"] = names.Split(',').ToJson();}},
            {"attachment=|attachments=", "", files => {config["attachments"] = files.Split(',').ToJson();}}, //can be the path or raw file, but all types must be the same for this up and comming version

            {"d=|delimiter=", "", sep => {Echo.DELIMITER = sep;}},
            {"l=|log-level=", "", noise => {Echo.LOG_LEVEL = Convert.ToByte(noise);}},

            /*
            later...
            get-tasks

            team-name=

            output-type= json csv none(same as log-level 0) cli(default)
            */
            };

            var badInput = options.Parse(args);

            Echo.WelcomeText();

            if(badInput.Count > 0 || SESSION_ACTION == TAI_COMMAND.NONE) {
                Echo.ErrorReport(badInput.ToArray());
                Echo.OffensiveGesture();
                Echo.HelpText(options);
            }

            config = Grapple.TryGetCredentialsManually(config);
            ApiWrapper.Initialize(config);

            TaiTakeCareOfThis[SESSION_ACTION](config);

            Echo.Out("done", 5);
        }