// // aegis - project change supervisor // Copyright (C) 2013 Peter Miller // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or (at // your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program. If not, see . // #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include enum { arglex_token3_ae_repo_ci = ARGLEX2_MAX, arglex_token3_aede_policy, arglex_token3_aedist, arglex_token3_aefind, arglex_token3_aefinish, arglex_token3_aegource, arglex_token3_aegrep, arglex_token3_aeimport, arglex_token3_aelcf, arglex_token3_aelock, arglex_token3_aelpf, arglex_token3_aelsf, arglex_token3_aemakegen, arglex_token3_aemeasure, arglex_token3_aepatch, arglex_token3_aerevml, arglex_token3_aesub, arglex_token3_aetar, arglex_token3_aexml, arglex_token3_annotate, arglex_token3_merge, }; // // Keep this argument table sorted "LANG=C sort -f" // static arglex_table_ty argtab3[] = { { "_ANNotate", arglex_token3_annotate }, { "_BLAme", arglex_token3_annotate }, { "_Build", arglex_token_build, }, { "_Change_Attributes", arglex_token_change_attributes, }, { "_Change_Directory", arglex_token_change_directory, }, { "_Change_Owner", arglex_token_change_owner, }, { "_CLEan", arglex_token_clean, }, { "_CLOne", arglex_token_clone, }, { "_CONFIGured", arglex_token_configured, }, { "_CoPy_file", arglex_token_copy_file, }, { "_CoPy_file_Undo", arglex_token_copy_file_undo, }, { "_Delta_Name", arglex_token_delta_name, }, { "_Descend_Project_Tree", arglex_token_project_recursive, }, { "_Develop_Begin", arglex_token_develop_begin, }, { "_Develop_Begin_Undo", arglex_token_develop_begin_undo, }, { "_Develop_End", arglex_token_develop_end, }, { "_Develop_End_Policy", arglex_token3_aede_policy }, { "_Develop_End_Undo", arglex_token_develop_end_undo, }, { "_DIFference", arglex_token_difference, }, { "_DIStribute", arglex_token3_aedist }, { "_File_ATtributes", arglex_token_file_attributes, }, { "_FIND", arglex_token3_aefind }, { "_FINIsh", arglex_token3_aefinish }, { "_Fix_ARchitectures", arglex_token_fix_architecture, }, { "_GOurce", arglex_token3_aegource }, { "_GRep", arglex_token3_aegrep }, { "_Help", arglex_token_help }, { "_IMport", arglex_token3_aeimport }, { "_Integrate_Begin", arglex_token_integrate_begin, }, { "_Integrate_Begin_Undo", arglex_token_integrate_begin_undo, }, { "_Integrate_Fail", arglex_token_integrate_fail, }, { "_Integrate_Pass", arglex_token_integrate_pass, }, { "_List", arglex_token_list, }, { "_List_Change_Files", arglex_token3_aelcf }, { "_List_Project_Files", arglex_token3_aelpf }, { "_List_Source_Files", arglex_token3_aelsf }, { "_LOCk", arglex_token3_aelock }, { "_Makefile_Genenerator", arglex_token3_aemakegen }, { "_Make_Transparent", arglex_token_make_transparent, }, { "_Make_Transparent_Undo", arglex_token_make_transparent_undo, }, { "_MEAsure", arglex_token3_aemeasure }, { "_MERge", arglex_token3_merge, }, { "_MoVe_file", arglex_token_move_file, }, { "_MoVe_file_Undo", arglex_token_move_file_undo, }, { "_New_Administrator", arglex_token_new_administrator, }, { "_New_BRanch", arglex_token_new_branch, }, { "_New_BRanch_Undo", arglex_token_new_branch_undo, }, { "_New_Change", arglex_token_new_change, }, { "_New_Change_Undo", arglex_token_new_change_undo, }, { "_New_Developer", arglex_token_new_developer, }, { "_New_File", arglex_token_new_file, }, { "_New_File_Undo", arglex_token_new_file_undo, }, { "_New_Integrator", arglex_token_new_integrator, }, { "_New_Project", arglex_token_new_project, }, { "_New_Project_Alias", arglex_token_project_alias_create, }, { "_New_ReViewer", arglex_token_new_reviewer, }, { "_New_Test", arglex_token_new_test, }, { "_New_Test_Undo", arglex_token_new_test_undo, }, { "_Not_CONFIGured", arglex_token_configured_not, }, { "_PATCh", arglex_token3_aepatch }, { "_Print_Working_Directory", arglex_token_change_directory, }, { "_Project_Attributes", arglex_token_project_attributes, }, { "_Query", arglex_token_report }, { "_Remove_Administrator", arglex_token_remove_administrator, }, { "_Remove_Developer", arglex_token_remove_developer, }, { "_ReMove_file", arglex_token_remove_file, }, { "_ReMove_file_Undo", arglex_token_remove_file_undo, }, { "_Remove_Integrator", arglex_token_remove_integrator, }, { "_ReMove_PRoject", arglex_token_remove_project, }, { "_Remove_Project_Alias", arglex_token_project_alias_remove, }, { "_Remove_ReViewer", arglex_token_remove_reviewer, }, { "_REName", arglex_token_move_file }, { "_REName_Undo", arglex_token_move_file_undo }, { "_RePorT", arglex_token_report, }, { "_REPOsitory_Check_In", arglex_token3_ae_repo_ci }, { "_Review_Begin", arglex_token_review_begin, }, { "_Review_Begin_Undo", arglex_token_review_begin_undo, }, { "_Review_Fail", arglex_token_review_fail, }, { "_Review_PASs", arglex_token_review_pass, }, { "_Review_Pass_Undo", arglex_token_review_pass_undo, }, { "_Revision_Markup_Language", arglex_token3_aerevml }, { "_Substitute", arglex_token3_aesub }, { "_Tape_ARchive", arglex_token3_aetar }, { "_Test", arglex_token_test, }, { "_Verify_Symbolic_Links", arglex_token_symbolic_links, }, { "_VERsion", arglex_token_version }, { "_X_Markup_Language", arglex_token3_aexml }, ARGLEX_END_MARKER }; static void main_help(void) { help((char *)0, usage); } static void list(void); // forward static const arglex_dispatch_ty dispatch[] = { { arglex_token_build, build, 0 }, { arglex_token_change_attributes, change_attributes, 0 }, { arglex_token_change_directory, change_directory, 0 }, { arglex_token_change_owner, change_owner, 0 }, { arglex_token_clean, clean, 0 }, { arglex_token_clone, clone, 0 }, { arglex_token_configured, configured, 0 }, { arglex_token_copy_file, copy_file, 0 }, { arglex_token_copy_file_undo, copy_file_undo, 0 }, { arglex_token_develop_begin, develop_begin, 0 }, { arglex_token_develop_begin_undo, develop_begin_undo, 0 }, { arglex_token_develop_end, develop_end, 0 }, { arglex_token_develop_end_undo, develop_end_undo, 0 }, { arglex_token_difference, difference, 0 }, { arglex_token_delta_name, delta_name, 0 }, { arglex_token_file_attributes, file_attributes, 0 }, { arglex_token_integrate_begin, integrate_begin, 0 }, { arglex_token_integrate_begin_undo, integrate_begin_undo, 0 }, { arglex_token_integrate_fail, integrate_fail, 0 }, { arglex_token_integrate_pass, integrate_pass, 0 }, { arglex_token_move_file, move_file, 0 }, { arglex_token_move_file_undo, move_file_undo, 0 }, { arglex_token_new_administrator, new_administrator, 0 }, { arglex_token_new_branch, new_branch, 0 }, { arglex_token_new_branch_undo, new_branch_undo, 0 }, { arglex_token_new_change, new_change, 0 }, { arglex_token_new_change_undo, new_change_undo, 0 }, { arglex_token_new_developer, new_developer, 0 }, { arglex_token_make_transparent, make_transparent, 0 }, { arglex_token_make_transparent_undo, make_transparent_undo, 0 }, { arglex_token_new_file, new_file, 0 }, { arglex_token_new_file_undo, new_file_undo, 0 }, { arglex_token_new_integrator, new_integrator, 0 }, { arglex_token_new_project, new_project, 0 }, { arglex_token_new_release, new_release, 0 }, { arglex_token_new_reviewer, new_reviewer, 0 }, { arglex_token_new_test, new_test, 0 }, { arglex_token_new_test_undo, new_test_undo, 0 }, { arglex_token_project_attributes, project_attributes, 0 }, { arglex_token_project_alias_create, project_alias_create, 0 }, { arglex_token_project_alias_remove, project_alias_remove, 0 }, { arglex_token_remove_administrator, remove_administrator, 0 }, { arglex_token_remove_developer, remove_developer, 0 }, { arglex_token_remove_file, remove_file, 0 }, { arglex_token_remove_file_undo, remove_file_undo, 0 }, { arglex_token_remove_project, remove_project, 0 }, { arglex_token_remove_integrator, remove_integrator, 0 }, { arglex_token_remove_reviewer, remove_reviewer, 0 }, { arglex_token_report, report, 0 }, { arglex_token_review_begin, review_begin, 0 }, { arglex_token_review_begin_undo, review_begin_undo, 0 }, { arglex_token_review_fail, review_fail, 0 }, { arglex_token_review_pass, review_pass, 0 }, { arglex_token_review_pass_undo, review_pass_undo, 0 }, { arglex_token_test, test, 0 }, { arglex_token3_ae_repo_ci, ae_repo_ci, 0 }, { arglex_token3_aede_policy, aede_policy, 0 }, { arglex_token3_aedist, aedist, 0 }, { arglex_token3_aefind, aefind, 0 }, { arglex_token3_aefinish, aefinish, 0 }, { arglex_token3_aegource, aegource, 0 }, { arglex_token3_aegrep, aegrep, 0 }, { arglex_token3_aeimport, aeimport, 0 }, { arglex_token3_aelcf, aelcf, 0 }, { arglex_token3_aelock, aelock, 0 }, { arglex_token3_aelpf, aelpf, 0 }, { arglex_token3_aelsf, aelsf, 0 }, { arglex_token3_aemakegen, aemakegen, 0 }, { arglex_token3_aemeasure, aemeasure, 0 }, { arglex_token3_aepatch, aepatch, 0 }, { arglex_token3_aerevml, aerevml, 0 }, { arglex_token3_aesub, aesub, 0 }, { arglex_token3_aetar, aetar, 0 }, { arglex_token3_aexml, aexml, 0 }, { arglex_token3_annotate, annotate, 0 }, { arglex_token3_merge, merge, 0 }, // // Then there are the more ambiguous arguments. // These are only considered if none of the above are // present on the command line (help least of all, // because everything has help). // { arglex_token_version, version, 1 }, { arglex_token_list, list, 1 }, { arglex_token_help, main_help, 2 }, }; static void list(void) { size_t max_width = 15; for (const arglex_dispatch_ty *dp = dispatch; dp < ENDOF(dispatch); ++dp) { const char *s = arglex_token_name(dp->token); if (*s == '-' && dp->priority == 0) continue; size_t w = strlen(s); if (max_width < w) max_width = w; } for (const arglex_dispatch_ty *dp = dispatch; dp < ENDOF(dispatch); ++dp) { const char *s = arglex_token_name(dp->token); if (*s == '-' && dp->priority == 0) continue; nstring a = arglex_abbreviate(s); printf("%-*s %s\n", (int)max_width, s, a.c_str()); } } int main(int argc, char **argv) { // // initialize everything // progname_set(argv[0]); os_become_init_mortal(); arglex2_init3(argc, argv, argtab3); #ifdef DEBUG arglex_test_ambiguous(); #endif env_initialize(); language_init(); resource_limits_init(); // // Dispatch based on the command line. // arglex_dispatch(dispatch, SIZEOF(dispatch), usage); // // If we get to here, everything went OK. // quit(0); return 0; } // vim: set ts=8 sw=4 et :