Changeset 612 for CMT/HEAD


Ignore:
Timestamp:
Apr 26, 2012, 9:51:00 AM (12 years ago)
Author:
rybkin
Message:

See C.L. 487

Location:
CMT/HEAD
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • CMT/HEAD/ChangeLog

    r611 r612  
     12012-04-25    <rybkin@lal.in2p3.fr> 487
     2
     3        * source/cmt_commands.cxx: In class ArgParser function do_show, introduce
     4        commands "cmt show alias", "cmt show alias_names", "cmt show alias_value",
     5        "cmt show aliases", in class CommandHelp constructor, document new commands
     6        and document use of optional <regexp> argument for "cmt show" commands
     7        {action,macro,set}{s,_names}
     8        * source/cmt.h: In class Cmt, declare functions do_show_alias,
     9        do_show_alias_names, do_show_alias_value, do_show_aliases
     10        * source/cmt_parser.h: In enum ActionType, introduce members
     11        action_show_alias, action_show_alias_value, action_show_alias_names,
     12        action_show_aliases
     13        * source/cmt_parser.cxx: In class Cmt, implement functions do_show_alias,
     14        do_show_alias_names, do_show_alias_value, do_show_aliases, in function
     15        do_show_macro, implement function do_show_action via do_show_macro, enhance
     16        function do_show_macro to show actions and aliases, in function parser,
     17        make use of new alias related functions, in function print_symbol_names,
     18        add case of action_show_alias_names, in function print_macros, add case of
     19        action_show_aliases
     20        * source/cmt_symbol.cxx: In class Symbol function show_macro, add case of
     21        action_show_aliases, action_show_alias, action_show_alias_value
     22        * src/setup.csh: Fix case of unset environment variable CLASSPATH, optimise
     23        tcsh shell is identification
     24        * src/setup.bash: Implement command completion for alias related commands
     25        * src/setup.zsh: idem
     26        * src/setup.tcsh: idem, optimise by removing redundant sed utility
     27        invocations
     28       
    1292012-04-24    <rybkin@lal.in2p3.fr> 486
    230
  • CMT/HEAD/source/cmt.h

    r588 r612  
    160160  static void do_show_action_value (const ArgParser& ap);
    161161  static void do_show_actions (const ArgParser& ap);
     162  static void do_show_alias (const ArgParser& ap);
     163  static void do_show_alias_names (const ArgParser& ap);
     164  static void do_show_alias_value (const ArgParser& ap);
     165  static void do_show_aliases (const ArgParser& ap);
    162166  static void do_show_all_tags (const ArgParser& ap);
    163167  static void do_show_applied_patterns (const ArgParser& ap);
  • CMT/HEAD/source/cmt_commands.cxx

    r599 r612  
    14081408
    14091409          cmt.m_action = action_show_actions;
     1410        }
     1411      else if (arg == "alias")
     1412        {
     1413          if (argc > 0)
     1414            {
     1415              cmt.m_current_target = fill_one_argument ();
     1416              cmt.m_action = action_show_alias;
     1417            }
     1418          else
     1419            {
     1420              CmtError::set (CmtError::syntax_error, "alias name missing");
     1421              //CmtMessage::error ("syntax: alias name missing");
     1422              help_action = action_help;
     1423              cmt.m_action = action_show_alias;
     1424            }
     1425        }
     1426      else if (arg == "alias_names")
     1427        {
     1428          if (argc > 0)
     1429            {
     1430              fill_one_argument ();
     1431            }
     1432
     1433          cmt.m_action = action_show_alias_names;
     1434        }
     1435      else if (arg == "alias_value")
     1436        {
     1437          cmt.m_quiet = true;
     1438          if (argc > 0)
     1439            {
     1440              cmt.m_current_target = fill_one_argument ();
     1441              cmt.m_action = action_show_alias_value;
     1442            }
     1443          else
     1444            {
     1445              CmtError::set (CmtError::syntax_error, "alias name missing");
     1446              //CmtMessage::error ("syntax: alias name missing");
     1447              help_action = action_help;
     1448              cmt.m_action = action_show_alias_value;
     1449            }
     1450        }
     1451      else if (arg == "aliases")
     1452        {
     1453          if (argc > 0)
     1454            {
     1455              fill_one_argument ();
     1456            }
     1457
     1458          cmt.m_action = action_show_aliases;
    14101459        }
    14111460      else if (arg == "all_tags")
     
    24732522  help_texts.add () =  "show  action <name>     :  a formatted action definition";
    24742523  help_texts.add () =  "show  action_value <name> :  a raw action definition";
    2475   help_texts.add () =  "show  action_names      :  all action names";
    2476   help_texts.add () =  "show  actions           :  all action definitions";
     2524  help_texts.add () =  "show  action_names [<regexp>] :  all action names [matching <regexp>]";
     2525  help_texts.add () =  "show  actions [<regexp>] :  all action definitions [for names matching <regexp>]";
     2526  help_texts.add () =  "show  alias <name>      :  a formatted alias definition";
     2527  help_texts.add () =  "show  alias_value <name> :  a raw alias definition";
     2528  help_texts.add () =  "show  alias_names [<regexp>] :  all alias names [matching <regexp>]";
     2529  help_texts.add () =  "show  aliases [<regexp>] :  all alias definitions [for names matching <regexp>]";
    24772530  help_texts.add () =  "show  all_tags          :  all defined tags";
    24782531  help_texts.add () =  "show  applied_patterns  :  all patterns actually applied";
     
    24942547  help_texts.add () =  "show  macro <name>      :  a formatted macro definition";
    24952548  help_texts.add () =  "show  macro_value <name>  :  a raw macro definition";
    2496   help_texts.add () =  "show  macro_names       :  all macro names";
    2497   help_texts.add () =  "show  macros            :  all macro definitions";
     2549  help_texts.add () =  "show  macro_names [<regexp>] :  all macro names [matching <regexp>]";
     2550  help_texts.add () =  "show  macros [<regexp>] :  all macro definitions [for names matching <regexp>]";
    24982551  help_texts.add () =  "show  manager           :  package manager";
    24992552  help_texts.add () =  "show  packages [<path>]... :  packages reachable from the current context [or <path>s]";
     
    25072560  help_texts.add () =  "show  pwd               :  filtered current directory";
    25082561  help_texts.add () =  "show  set <name>        :  a formatted set definition";
    2509   help_texts.add () =  "show  set_names         :  set names";
     2562  help_texts.add () =  "show  set_names [<regexp>] :  set names [matching <regexp>]";
    25102563  help_texts.add () =  "show  set_value <name>  :  a raw set definition";
    2511   help_texts.add () =  "show  sets              :  set definitions";
     2564  help_texts.add () =  "show  sets [<regexp>]   :  set definitions [for names matching <regexp>]";
    25122565  help_texts.add () =  "show  strategies        :  all strategies (build & version)";
    25132566  help_texts.add () =  "show  tags              :  all currently active tags";
     
    25772630  help.add (action_show_action_names, help_texts[action_show_action_names]);
    25782631  help.add (action_show_actions, help_texts[action_show_actions]);
     2632  help.add (action_show_alias, help_texts[action_show_alias]);
     2633  help.add (action_show_alias_value, help_texts[action_show_alias_value]);
     2634  help.add (action_show_alias_names, help_texts[action_show_alias_names]);
     2635  help.add (action_show_aliases, help_texts[action_show_aliases]);
    25792636  help.add (action_show_all_tags, help_texts[action_show_all_tags]);
    25802637  help.add (action_show_applied_patterns, help_texts[action_show_applied_patterns]);
  • CMT/HEAD/source/cmt_parser.cxx

    r610 r612  
    43534353void Cmt::do_show_action (const ArgParser& ap)
    43544354{
    4355   cmt_string target;
    4356 
    4357   if (ap.arguments.size () > 0) target = ap.arguments[0];
    4358 
    4359   Symbol* symbol;
    4360 
    4361   set_standard_macros ();
    4362 
    4363   symbol = Symbol::find (target);
    4364 
    4365   if (symbol == 0)
    4366     {
    4367       cmt_string t (target);
    4368       t += " is not defined";
    4369 
    4370       CmtError::set (CmtError::symbol_not_found, t);
    4371 
    4372       return;
    4373     }
    4374   else
    4375     {
    4376       cmt_string t = target;
    4377       t += " is a ";
    4378 
    4379       if ((Me.m_action == action_show_action) ||
    4380           (Me.m_action == action_show_action_value))
    4381         {
    4382           if (symbol->type != Symbol::SymbolAction)
    4383             {
    4384               if (symbol->type == Symbol::SymbolMacro)
    4385                 {
    4386                   t += "macro";
    4387                 }
    4388               else if (symbol->type == Symbol::SymbolSet)
    4389                 {
    4390                   t += "set";
    4391                 }
    4392               else if (symbol->type == Symbol::SymbolPath)
    4393                 {
    4394                   t += "path";
    4395                 }
    4396               else if (symbol->type == Symbol::SymbolAlias)
    4397                 {
    4398                   t += "alias";
    4399                 }
    4400 
    4401               CmtError::set (CmtError::wrong_symbol_type, t);
    4402             }
    4403         }
    4404     }
    4405 
    4406   if (symbol->value_lists.size () < 1) return;
    4407 
    4408   symbol->show_macro (ap.mode);
     4355  do_show_macro (ap);
    44094356}
    44104357
     
    44314378//----------------------------------------------------------
    44324379void Cmt::do_show_actions (const ArgParser& ap)
     4380{
     4381  if (ap.arguments.size () > 0)
     4382    {
     4383      const cmt_string& pattern = ap.arguments[0];
     4384      print_macros (ap.mode, pattern);
     4385    }
     4386  else
     4387    {
     4388      print_macros (ap.mode);
     4389    }
     4390}
     4391
     4392//----------------------------------------------------------
     4393void Cmt::do_show_alias (const ArgParser& ap)
     4394{
     4395  do_show_macro (ap);
     4396}
     4397
     4398//----------------------------------------------------------
     4399void Cmt::do_show_alias_names (const ArgParser& ap)
     4400{
     4401  if (ap.arguments.size () > 0)
     4402    {
     4403      const cmt_string& pattern = ap.arguments[0];
     4404      print_symbol_names (ap.mode, pattern);
     4405    }
     4406  else
     4407    {
     4408      print_symbol_names (ap.mode);
     4409    }
     4410}
     4411
     4412//----------------------------------------------------------
     4413void Cmt::do_show_alias_value (const ArgParser& ap)
     4414{
     4415  do_show_macro (ap);
     4416}
     4417
     4418//----------------------------------------------------------
     4419void Cmt::do_show_aliases (const ArgParser& ap)
    44334420{
    44344421  if (ap.arguments.size () > 0)
     
    47174704    {
    47184705      cmt_string t = target;
    4719       t += " is a ";
     4706      t += " is ";
    47204707
    47214708      if ((Me.m_action == action_show_macro) ||
     
    47594746            }
    47604747        }
     4748      else if (
     4749               ((Me.m_action == action_show_action ||
     4750                 Me.m_action == action_show_action_value) &&
     4751                symbol->type != Symbol::SymbolAction)
     4752               ||
     4753               ((Me.m_action == action_show_alias ||
     4754                 Me.m_action == action_show_alias_value) &&
     4755                symbol->type != Symbol::SymbolAlias)
     4756               )
     4757        {
     4758          switch (symbol->type)
     4759            {
     4760            case Symbol::SymbolUndefined:
     4761              t += "undefined";
     4762              break;
     4763            case Symbol::SymbolAction:
     4764              t += "action";
     4765              break;
     4766            case Symbol::SymbolAlias:
     4767              t += "alias";
     4768              break;
     4769            case Symbol::SymbolMacro:
     4770              t += "macro";
     4771              break;
     4772            case Symbol::SymbolSetupScript:
     4773              t += "setup_script";
     4774              break;
     4775            case Symbol::SymbolCleanupScript:
     4776              t += "cleanup_script";
     4777              break;
     4778            case Symbol::SymbolSet:
     4779              t += "set";
     4780              break;
     4781            case Symbol::SymbolPath:
     4782              t += "path";
     4783              break;
     4784            default:
     4785              t += "unknown";
     4786              break;
     4787            }
     4788         
     4789          CmtError::set (CmtError::wrong_symbol_type, t);
     4790        }
    47614791    }
    47624792
     
    66056635    case action_show_action_value :
    66066636    case action_show_actions :
     6637    case action_show_alias :
     6638    case action_show_alias_names :
     6639    case action_show_alias_value :
     6640    case action_show_aliases :
    66076641    case action_show_all_tags :
    66086642    case action_show_applied_patterns :
     
    67246758    case action_show_action_value :
    67256759    case action_show_actions :
     6760    case action_show_alias :
     6761    case action_show_alias_names :
     6762    case action_show_alias_value :
     6763    case action_show_aliases :
    67266764    case action_show_all_tags :
    67276765    case action_show_applied_patterns :
     
    68326870    case action_show_action_value :
    68336871    case action_show_actions :
     6872    case action_show_alias :
     6873    case action_show_alias_names :
     6874    case action_show_alias_value :
     6875    case action_show_aliases :
    68346876    case action_show_all_tags :
    68356877    case action_show_applied_patterns :
     
    69807022          // case action_show_action_value :
    69817023          // case action_show_actions :
     7024          // case action_show_alias :
     7025          // case action_show_alias_names :
     7026          // case action_show_alias_value :
     7027          // case action_show_aliases :
    69827028          // case action_show_all_tags :
    69837029          // case action_show_applied_patterns :
     
    71937239          do_show_actions (ap);
    71947240          break;
     7241        case action_show_alias :
     7242          do_show_alias (ap);
     7243          break;
     7244        case action_show_alias_names :
     7245          do_show_alias_names (ap);
     7246          break;
     7247        case action_show_alias_value :
     7248          do_show_alias_value (ap);
     7249          break;
     7250        case action_show_aliases :
     7251          do_show_aliases (ap);
     7252          break;
    71957253        case action_show_all_tags :
    71967254          do_show_all_tags (ap);
     
    77607818      else if (Me.m_action == action_show_set_names)
    77617819        {
    7762           // Exclude macros.
     7820          // Exclude macros, actions.
    77637821          if ((symbol.type == Symbol::SymbolMacro) ||
    77647822              (symbol.type == Symbol::SymbolAction)) continue;
     
    77667824      else if (Me.m_action == action_show_action_names)
    77677825        {
    7768           // Exclude macros.
     7826          // Only keep actions.
    77697827          if (symbol.type != Symbol::SymbolAction) continue;
     7828        }
     7829      else if (Me.m_action == action_show_alias_names)
     7830        {
     7831          // Only keep aliases.
     7832          if (symbol.type != Symbol::SymbolAlias) continue;
    77707833        }
    77717834
     
    78277890        {
    78287891          if (symbol.type != Symbol::SymbolAction) continue;
     7892        }
     7893      else if (Me.m_action == action_show_aliases)
     7894        {
     7895          if (symbol.type != Symbol::SymbolAlias) continue;
    78297896        }
    78307897
  • CMT/HEAD/source/cmt_parser.h

    r588 r612  
    281281  action_show_action_names,
    282282  action_show_actions,
     283  action_show_alias,
     284  action_show_alias_value,
     285  action_show_alias_names,
     286  action_show_aliases,
    283287  action_show_all_tags,
    284288  action_show_applied_patterns,
  • CMT/HEAD/source/cmt_symbol.cxx

    r611 r612  
    19431943      (action != action_show_macros) &&
    19441944      (action != action_show_actions) &&
     1945      (action != action_show_aliases) &&
    19451946      (action != action_show_sets))
    19461947    {
     
    19571958          (action == action_show_actions) ||
    19581959          (action == action_show_action) ||
     1960          (action == action_show_alias) ||
     1961          (action == action_show_aliases) ||
    19591962          (action == action_build_tag_makefile) ||
    19601963          (action == action_build_constituents_config) ||
     
    19761979      if ((action == action_show_macro_value) ||
    19771980          (action == action_show_set_value) ||
    1978           (action == action_show_action_value))
     1981          (action == action_show_action_value) ||
     1982          (action == action_show_alias_value))
    19791983        {
    19801984          expand (value);
     
    20042008          (action == action_show_actions) ||
    20052009          (action == action_show_action) ||
     2010          (action == action_show_alias) ||
     2011          (action == action_show_aliases) ||
    20062012          (action == action_build_tag_makefile) ||
    20072013          (action == action_build_constituents_config) ||
  • CMT/HEAD/src/setup.bash

    r586 r612  
    2525    local build_subcmds=(CMT_pacman constituent_makefile constituents_makefile dependencies library_links make_setup msdev os9_makefile prototype readme tag_makefile temporary_name triggers win_makefile)
    2626    local check_subcmds=(configuration files version)
    27     local show_subcmds=(action action_names action_value actions all_tags applied_patterns author branches clients cmtpath_patterns constituent constituent_names constituents container cycles fragment fragments groups include_dirs language languages macro macro_names macro_value macros manager packages path pattern patterns projects project_author pwd set set_names set_value sets strategies tags use_paths uses versions)
     27    local show_subcmds=(action action_names action_value actions alias alias_names alias_value aliases all_tags applied_patterns author branches clients cmtpath_patterns constituent constituent_names constituents container cycles fragment fragments groups include_dirs language languages macro macro_names macro_value macros manager packages path pattern patterns projects project_author pwd set set_names set_value sets strategies tags use_paths uses versions)
    2828
    2929    local cur _IFS="${IFS}"
     
    122122                        if (( isubcommand + 1 == COMP_CWORD )); then
    123123                            COMPREPLY=($(compgen -W "$(cmt -quiet show action_names)" -- "$cur"))
     124                        fi
     125                        ;;
     126                    alias|alias_value)
     127                        if (( isubcommand + 1 == COMP_CWORD )); then
     128                            COMPREPLY=($(compgen -W "$(cmt -quiet show alias_names)" -- "$cur"))
    124129                        fi
    125130                        ;;
  • CMT/HEAD/src/setup.csh

    r611 r612  
    1313
    1414if ( $?0 == 0 ) then
    15 if ( $?tcsh == 1 || `basename "$shell"` == "tcsh" ) then
     15if ( $?tcsh == 1 ) then
     16  source ${CMTROOT}/src/setup.tcsh
     17else if ( `basename "$shell"` == "tcsh" ) then
    1618  source ${CMTROOT}/src/setup.tcsh
    1719endif
     
    3335unset newpath
    3436
    35 if ( $?CLASSPATH == 0 || "${CLASSPATH}" == "" ) then
     37if ( $?CLASSPATH == 0 ) then
     38  setenv CLASSPATH ${CMTROOT}/java/cmt.jar
     39else if ( "${CLASSPATH}" == "" ) then
    3640  setenv CLASSPATH ${CMTROOT}/java/cmt.jar
    3741else if ( "${CLASSPATH}" !~ "*/CMT/*" ) then
  • CMT/HEAD/src/setup.tcsh

    r585 r612  
    1414 n/check_files/f/ \
    1515 n/expand/'(model)'/ \
    16  n/show/'(action action_names action_value actions all_tags applied_patterns author branches clients cmtpath_patterns constituent constituent_names constituents container cycles fragment fragments groups include_dirs language languages macro macro_names macro_value macros manager packages path pattern patterns projects project_author pwd set set_names set_value sets strategies tags use_paths uses versions)'/ \
     16 n/show/'(action action_names action_value actions alias alias_names alias_value aliases all_tags applied_patterns author branches clients cmtpath_patterns constituent constituent_names constituents container cycles fragment fragments groups include_dirs language languages macro macro_names macro_value macros manager packages path pattern patterns projects project_author pwd set set_names set_value sets strategies tags use_paths uses versions)'/ \
    1717 n/constituents_makefile/n/ \
    1818 n/constituent/'`cmt -quiet show constituent_names`'/ \
    19  n/fragment/'`cmt -quiet show fragments | sed -e "s#.*fragments.##" `'/ \
    20  n/action/'`cmt -quiet show action_names | sed -e "s#=.*##" `'/ \
    21  n/action_value/'`cmt -quiet show action_names | sed -e "s#=.*##" `'/ \
    22  n/macro/'`cmt -quiet show macro_names | sed -e "s#=.*##" `'/ \
    23  n/macro_value/'`cmt -quiet show macro_names | sed -e "s#=.*##" `'/ \
     19 n@fragment@'`cmt -quiet show fragments | sed -e "s#.*/fragments/##"`'@ \
     20 n/action/'`cmt -quiet show action_names`'/ \
     21 n/action_value/'`cmt -quiet show action_names`'/ \
     22 n/alias/'`cmt -quiet show alias_names`'/ \
     23 n/alias_value/'`cmt -quiet show alias_names`'/ \
     24 n/macro/'`cmt -quiet show macro_names`'/ \
     25 n/macro_value/'`cmt -quiet show macro_names`'/ \
    2426 n/pattern/'`cmt -quiet show pattern_names`'/ \
    25  n/set/'`cmt -quiet show set_names | sed -e "s#=.*##" `'/ \
    26  n/set_value/'`cmt -quiet show set_names | sed -e "s#=.*##" `'/ \
     27 n/set/'`cmt -quiet show set_names`'/ \
     28 n/set_value/'`cmt -quiet show set_names`'/ \
    2729 n/triggers/'`cmt -quiet show constituent_names`'/ \
    2830 'n/c{o,heckout}/(-l -R -r -C -i -vd -d -o -requirements -no_config -rs --help)/' \
  • CMT/HEAD/src/setup.zsh

    r585 r612  
    1010function cmt_macros { reply=(`cmt -quiet show macro_names`)}; \
    1111   function cmt_actions { reply=(`cmt -quiet show action_names`)}; \
     12   function cmt_aliases { reply=(`cmt -quiet show alias_names`)}; \
    1213   function cmt_sets { reply=(`cmt -quiet show set_names`)}; \
    1314   function cmt_constituents { reply=(`cmt -quiet show constituent_names`) }; \
     
    3233   'w[1,remove] p[3]' -X '> give version tag' - \
    3334   'w[1,remove] p[4]' -X '> give a path if not located from the current path ' - \
    34    's[show],c[-1,show]' -k '(action,action_names,action_value,actions,all_tags,applied_patterns,author,branches,clients,cmtpath_patterns,constituent,constituent_names,constituents,container,cycles,fragment,fragments,groups,include_dirs,language,languages,macro,macro_names,macro_value,macros,manager,packages,path,pattern,patterns,projects,project_author,pwd,set,set_names,set_value,sets,strategies,tags,use_paths,uses,versions)' - \
     35   's[show],c[-1,show]' -k '(action,action_names,action_value,actions,alias,alias_names,alias_value,aliases,all_tags,applied_patterns,author,branches,clients,cmtpath_patterns,constituent,constituent_names,constituents,container,cycles,fragment,fragments,groups,include_dirs,language,languages,macro,macro_names,macro_value,macros,manager,packages,path,pattern,patterns,projects,project_author,pwd,set,set_names,set_value,sets,strategies,tags,use_paths,uses,versions)' - \
    3536   'w[1,show] c[-1,constituent]' -K cmt_constituents - \
    3637   'w[1,show] c[-1,fragment]' -K cmt_fragments - \
    3738   'w[1,show] c[-1,action]' -K cmt_actions - \
    3839   'w[1,show] c[-1,action_value]' -K cmt_actions - \
     40   'w[1,show] c[-1,alias]' -K cmt_aliases - \
     41   'w[1,show] c[-1,alias_value]' -K cmt_aliases - \
    3942   'w[1,show] c[-1,macro]' -K cmt_macros - \
    4043   'w[1,show] c[-1,macro_value]' -K cmt_macros - \
Note: See TracChangeset for help on using the changeset viewer.