0

私は最近、Windows-7 の文字数制限を回避することに関する、スーパー ユーザーに関する質問CMDをしました。これが私の質問でした:

メールを生成するスクリプトがあります。

[18:35:50]Creating resolution ticket..
Enter ticket number: 
Enter users full name: 
Enter summary of issue: 
Enter what will happen or what you did: Hello ma'am, it has come to my attention that according to <agency> regulation and policy, if I where to get this escalated, they WILL NOT edit the registry. For some reason <agency> only allows a certain size, and I can not change that. My best advice to you, is
[18:37:27]Copied to clipboard press CNTRL-V to paste

ご覧のとおり、メールの生成が完了する前に、コマンド ラインの文字制限が切れています。私の質問は、cmd を編集する方法、またはこの制限を回避する方法はありますか?

ただし、cmd の制限は 8191 文字であると指摘されていたので、それに近いとは思いませんが、スクリプトは実行されるたびに特定の時点で切り取られます。スクリプト全体 (ほとんどはテンプレートのみ) を提供することはできませんが、メイン ファイルと実行中のいくつかの写真を提供することはできます。

#!/usr/local/bin/env ruby


# Require all the files to make this thing run
# yes there are a lot most of them are modules
# that I created though.

require 'digest'
require 'date'
require 'etc'
require 'optparse'
require 'io/console'
require 'yaml'

require_relative 'lib/modules/clipboard'
require_relative 'lib/modules/date'
require_relative 'lib/modules/format'
require_relative 'lib/modules/time'
require_relative 'lib/email/version'
require_relative 'lib//modules/log_email'
require_relative 'lib/modules/email_templates'
require_relative 'lib/modules/admin/admin'

# Include the modules that are required from the
# lib/module directory

include Format
include DateCheck
include TimeCheck
include ClipBrd
include Email
include LogEmail
include Templates
include Admin

OPTIONS = {}

# Create the flags and append them to the empty hash in 
# order to easily call the flags from the hash. This makes 
# it easier to be able to find out which flag was given as
# an ARGV. If no ARGV is geven during the time of the command
# the program will default to the help page

OptionParser.new do |opts|
  opts.on('-h', '--help', 'Generate the help page'){ |o| OPTIONS[:help] = o }
  opts.on('-t INPUT', '--type INPUT', 'Specify the type of email to be generated'){ |o| OPTIONS[:type] = o }
  opts.on('--example', 'Gives an example of a generic email that was created using this program'){ |o| OPTIONS[:example] = o }
  opts.on('--version', 'Displays the version number of the program'){ |o| OPTIONS[:version] = o }
  opts.on('--admin', 'Run as admin to check logged information'){ |o| OPTIONS[:admin] = o }
end.parse!

def help_page
  puts
  "\e[44mruby gen_email.rb -[h|t] <Type-of-email> --[example|version]\e[0m"
end

def res_group
  Format.prompt('Enter resolution group')
end

def name
  Format.prompt('Enter users full name')
end

def summary
  Format.prompt('Enter summary of issue')
end

def num
  Format.prompt('Enter ticket number')
end

def body
  Format.prompt('Enter what will happen or what you did')
end

def account
  Format.prompt('Enter users account')
end

def timestamp
  Format.prompt('Enter specific time stamp to be removed')
end

def check_date
  DateCheck.date
end

def header
  TimeCheck.check_time
end

def get_user
  user = Etc.getlogin
  @esd_user = user.split('_').first.capitalize + ' ' + user.split('_').last[0].upcase
end

def copy(email)
  File.open('./lib/tools/tmp/email_to_copy', 'w') { |s| s.puts(email) }
  LogEmail.log(email)
  clipbrd
end

def agency
  # Had to create my own because the prompt module
  # wasn't working..

  print "\e[36mEnter agency:\e[0m "
  STDIN.gets.chomp.upcase
end

def get_advocate
  res = agency
  file = YAML.load_file("lib/list.yml")
  file['agencies'][res].nil? ? "\e[33mInvalid agency\e[0m" : file['agencies'][res]
end

def clipbrd
  # Uses a batch file to create a copy of the 
  # email, the batch file works exactly like
  # the cmd command does. However I couldn't get 
  # the cmd copy command to work with the program
  # so I created a new one.

  ClipBrd.copy_to_clipbrd
  Format.info('Copied to clipboard press CNTRL-V to paste')
end

def gather_intel
  # Figure out what email the user wants to created
  # by checking the argument given to the -t flag

  case OPTIONS[:type]
    when /osha/
      Format.info('Creating OSHA Regional email..')
      osha_reg
    when /pend/
      Format.info('Creating 6 day hold pending email..')
      pend
    when /60/
      Format.info('Creating 60 day hold account deletion email..')
      sixty_day
    when /generic/
      Format.info('Creating generic email..')
      generic
    when /resolve/
      Format.info('Creating resolution ticket..')
      resolve    
    when /esc/
      Format.info('Creating escalation ticket..')
      assign
    when /remove/
      remove_pii
    else
      raise ArgumentError.new('Not a type of email, or wrong spelling')
  end
end

case
  # Figure out what the user wants to do. By
  # checking what flag is inside of the hash
  # at the time of the call

  when OPTIONS[:type]
    gather_intel
  when OPTIONS[:example]
    puts "\e[36m#{Templates.examples_page}\e[0m"
  when OPTIONS[:version]
    puts Email.version
  when OPTIONS[:admin]
    run_admin
  else
    puts help_page
end

汎用世代:

ここに画像の説明を入力

保留中の世代:

ここに画像の説明を入力

どんなタイプの電子メール生成を行っても、うまくいきません。私が提供できる情報があまりないため、誰かがこの質問に答えることができるとは本当に期待していませんが、これが何であるかについてのいくつかのアイデアは大歓迎です、ありがとう.

4

0 に答える 0