<commit_before>##########################################
#
# Module WorkflowMgr
#
##########################################
module WorkflowMgr

  ##########################################  
  #
  # Class WorkflowStatusOpt
  #
  ##########################################
  ### to call:  ./workflowstatusopt.rb -x junk -c "c1, c2, c3" -d dbfile -t "tk1, tk2, tk3"
  ###

  class WorkflowStatusOpt

    require 'optparse'
    require 'pp'                      
    require 'parsedate'
    
    attr_reader :database, :workflowdoc, :cycles, :tasks

    ##########################################  
    #
    # Initialize
    #
    ##########################################
    def initialize(args)

      @database=nil
      @workflowdoc=nil
      @cycles=''
      @tasks=[]
      parse(args)

    end  # initialize

  private

    ##########################################  
    #
    # parse
    #
    ##########################################
    def parse(args)

      OptionParser.new do |opts|

        # Command usage text
        opts.banner = "Usage:  workflowstatus -d database_file -w workflow_document [-c cycle_list] [-t task_list]"

        # Specify the database file
        opts.on("-d","--database file",String,"Path to database store file") do |db|
          @database=db
        end
     
        # Specify the XML file
        opts.on("-w","--workflow PATH",String,"Path to workflow definition file") do |workflowdoc|
          @workflowdoc=workflowdoc
        end

        # Cycles of interest
        #      C   C,C,C  C:C  :C   C:
        #        where C='YYYYMMDDHHMM', C:  >= C, :C  <= C

        opts.on("-c","--cycles 'c1,c2,c3' | 'c1:c2' | ':c' | 'c:' ",String,"List of cycles") do |clist|
          @cycles=clist
        end

        # Tasks of interest
        opts.on("-t","--tasks 'a,b,c'",Array,"List of tasks") do |tasklist|
          @tasks=tasklist
        end
     
        # Help
        opts.on("-h","--help","Show this message") do
          puts opts
          exit
        end

        begin

          # If no options are specified, turn on the help flag
          args=["-h"] if args.empty?

          # Parse the options
          opts.parse!(args)

          # The -d and -w options are mandatory
          raise OptionParser::ParseError,"A database file must be specified" if @database.nil?
          raise OptionParser::ParseError,"A workflow definition file must be specified" if @workflowdoc.nil?
  
        rescue OptionParser::ParseError => e
          STDERR.puts e.message, "\n",opts
          exit(-1)
        end
        
      end

      ###  
     
    end  # parse
<commit_msg>added summary option, -s   ** print out cycle summary only if this option is set added display by task option, -T   ** print info from the task perspective, if this option is set   ** otherwise, print from the cycle perspective<commit_after>##########################################
#
# Module WorkflowMgr
#
##########################################
module WorkflowMgr

  ##########################################  
  #
  # Class WorkflowStatusOpt
  #
  ##########################################
  ### to call:  ./workflowstatusopt.rb -x xmlfile -d dbfile [-c "c1, c2, c3"] [-t "tk1, tk2, tk3"] [-s]
  ###

  class WorkflowStatusOpt

    require 'optparse'
    require 'pp'                      
    require 'parsedate'
    
    attr_reader :database, :workflowdoc, :cycles, :tasks, :summary, :taskfirst

    ##########################################  
    #
    # Initialize
    #
    ##########################################
    def initialize(args)

      @database=nil
      @workflowdoc=nil
      @cycles=''
      @tasks=[]
      @summary='false'
      @taskfirst='false'
      parse(args)

    end  # initialize

  private

    ##########################################  
    #
    # parse
    #
    ##########################################
    def parse(args)

      OptionParser.new do |opts|

        # Command usage text
        opts.banner = "Usage:  workflowstatus -d database_file -w workflow_document [-c cycle_list] [-t task_list] [-s]"

        # Specify the database file
        opts.on("-d","--database file",String,"Path to database store file") do |db|
          @database=db
        end
     
        # Specify the XML file
        opts.on("-w","--workflow PATH",String,"Path to workflow definition file") do |workflowdoc|
          @workflowdoc=workflowdoc
        end

        # Cycles of interest
        #      C   C,C,C  C:C  :C   C:
        #        where C='YYYYMMDDHHMM', C:  >= C, :C  <= C

        opts.on("-c","--cycles 'c1,c2,c3' | 'c1:c2' | ':c' | 'c:' ",String,"List of cycles") do |clist|
          @cycles=clist
        end

        # Tasks of interest
        opts.on("-t","--tasks 'a,b,c'",Array,"List of tasks") do |tasklist|
          @tasks=tasklist
        end
     
        # cycle summary
        opts.on("-s","--summary","Cycle Summary") do 
          @summary=true
        end

        # display by task 
        opts.on("-T","--by_task","Display by Task") do 
          @taskfirst=true
        end

        # Help
        opts.on("-h","--help","Show this message") do
          puts opts
          exit
        end

        begin

          # If no options are specified, turn on the help flag
          args=["-h"] if args.empty?

          # Parse the options
          opts.parse!(args)

          # The -d and -w options are mandatory
          raise OptionParser::ParseError,"A database file must be specified" if @database.nil?
          raise OptionParser::ParseError,"A workflow definition file must be specified" if @workflowdoc.nil?
  
        rescue OptionParser::ParseError => e
          STDERR.puts e.message, "\n",opts
          exit(-1)
        end
        
      end

      ###  
     
    end  # parse

{'fraction_non_alphanumeric': 0.22027491408934707, 'fraction_numerical': 0.004123711340206186, 'mean_word_length': 2.1078483715963694, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 1}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3939502', 'n_tokens_mistral': 1715, 'n_tokens_neox': 1643, 'n_words': 448}