<commit_before>let s:V = gita#vital()
let s:Prelude = s:V.import('Prelude')
let s:Dict = s:V.import('Data.Dict')
let s:Prompt = s:V.import('Vim.Prompt')
let s:GitProcess = s:V.import('Git.Process')
let s:ArgumentParser = s:V.import('ArgumentParser')

function! s:translate(key, options, scheme) abort
  let value = a:options[a:key]
  if s:Prelude.is_list(value)
    return map(value, 's:translate(a:key, { a:key : v:val }, a:scheme)')
  elseif s:Prelude.is_number(value)
    return value ? [(len(a:key) == 1 ? '-' : '--') . a:key] : []
  else
    let value = value =~# '\s' ? printf("'%s'", value) : value
    return gita#process#splitargs(gita#util#formatter#format(
          \ a:scheme,
          \ { 'k': 'key', 'v': 'val' },
          \ { 'key': a:key, 'val': value },
          \))
  endif
endfunction

function! gita#process#args_from_options(options, schemes) abort
  let args = []
  for key in sort(keys(a:schemes))
    if !has_key(a:options, key)
      continue
    endif
    let scheme = s:Prelude.is_string(a:schemes[key])
          \ ? a:schemes[key]
          \ : len(key) == 1 ? '-%k%v' : '--%k%{=}v'
    call extend(args, s:translate(key, a:options, scheme))
  endfor
  return args
endfunction

function! gita#process#splitargs(args) abort
  let args = s:ArgumentParser.splitargs(a:args)
  let args = map(args, 's:ArgumentParser.strip_quotes(v:val)')
  let args = map(args, 'v:val ==# ''%'' ? gita#meta#expand(v:val) : v:val')
  return args
endfunction

function! gita#process#execute(git, args, ...) abort
  let options = extend({
        \ 'quiet': 0,
        \ 'fail_silently': 0,
        \ 'success_status': 0,
        \}, get(a:000, 0, {}))
  let args = filter(copy(a:args), '!empty(v:val)')
  let result = s:GitProcess.execute(a:git, args, s:Dict.omit(options, [
        \ 'quiet', 'fail_silently', 'success_status',
        \]))
  let is_success = result.status == options.success_status
  if !options.fail_silently && !is_success
    call s:GitProcess.throw(result)
  elseif !options.quiet
    call s:Prompt.debug(printf('%s: %s',
          \ is_success ? 'OK' : 'Fail',
          \ join(result.args),
          \))
    echo join(result.content, "\n")
  endif
  return result.content
endfunction

call gita#define_variables('process', {
      \ 'executable': 'git',
      \ 'arguments': ['-c', 'color.ui=false', '--no-pager'],
      \})

call s:GitProcess.set_config({
      \ 'executable': g:gita#process#executable,
      \ 'arguments':  g:gita#process#arguments,
      \})<commit_msg>Show what command has executed aftre gita#process#execute<commit_after>let s:V = gita#vital()
let s:Prelude = s:V.import('Prelude')
let s:Dict = s:V.import('Data.Dict')
let s:Prompt = s:V.import('Vim.Prompt')
let s:GitProcess = s:V.import('Git.Process')
let s:ArgumentParser = s:V.import('ArgumentParser')

function! s:translate(key, options, scheme) abort
  let value = a:options[a:key]
  if s:Prelude.is_list(value)
    return map(value, 's:translate(a:key, { a:key : v:val }, a:scheme)')
  elseif s:Prelude.is_number(value)
    return value ? [(len(a:key) == 1 ? '-' : '--') . a:key] : []
  else
    let value = value =~# '\s' ? printf("'%s'", value) : value
    return gita#process#splitargs(gita#util#formatter#format(
          \ a:scheme,
          \ { 'k': 'key', 'v': 'val' },
          \ { 'key': a:key, 'val': value },
          \))
  endif
endfunction

function! gita#process#args_from_options(options, schemes) abort
  let args = []
  for key in sort(keys(a:schemes))
    if !has_key(a:options, key)
      continue
    endif
    let scheme = s:Prelude.is_string(a:schemes[key])
          \ ? a:schemes[key]
          \ : len(key) == 1 ? '-%k%v' : '--%k%{=}v'
    call extend(args, s:translate(key, a:options, scheme))
  endfor
  return args
endfunction

function! gita#process#splitargs(args) abort
  let args = s:ArgumentParser.splitargs(a:args)
  let args = map(args, 's:ArgumentParser.strip_quotes(v:val)')
  let args = map(args, 'v:val ==# ''%'' ? gita#meta#expand(v:val) : v:val')
  return args
endfunction

function! gita#process#execute(git, args, ...) abort
  let options = extend({
        \ 'quiet': 0,
        \ 'fail_silently': 0,
        \ 'success_status': 0,
        \}, get(a:000, 0, {}))
  let args = filter(copy(a:args), '!empty(v:val)')
  let result = s:GitProcess.execute(a:git, args, s:Dict.omit(options, [
        \ 'quiet', 'fail_silently', 'success_status',
        \]))
  let is_success = result.status == options.success_status
  if !options.fail_silently && !is_success
    call s:GitProcess.throw(result)
  elseif !options.quiet
    call s:Prompt.title(printf('%s: %s',
          \ is_success ? 'OK' : 'Fail',
          \ join(result.args),
          \))
    echo join(result.content, "\n")
  endif
  return result.content
endfunction

call gita#define_variables('process', {
      \ 'executable': 'git',
      \ 'arguments': ['-c', 'color.ui=false', '--no-pager'],
      \})

call s:GitProcess.set_config({
      \ 'executable': g:gita#process#executable,
      \ 'arguments':  g:gita#process#arguments,
      \})
{'fraction_non_alphanumeric': 0.1835767864192657, 'fraction_numerical': 0.0035530990919857876, 'mean_word_length': 3.2759493670886077, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '3482746', 'n_tokens_mistral': 1906, 'n_tokens_neox': 1863, 'n_words': 364}