<commit_before>#!/bin/sh
#
# nanono - Nano notifications for Linux.
#
# https://github.com/macie/nanono
#
# Copyright (c) 2014 <NAME> <<EMAIL>>
# MIT License (http://opensource.org/licenses/MIT)


#
#   DEFAULTS
#

readonly _nanono_ver='0.1.0'


#
#   MESSAGES
#

help_message() {
  #
  # Shows help message.
  #
  # Returns:
  #     String message to standard output.
  #
  echo 'nanono - Nano notifications for Linux.'
  echo 'Usage:'
  echo '  nanono.sh [options]'
  echo 
  echo 'Options:'
  echo '  -h, --help              Show this help and exit.'
  echo '  -V, --version           Show version number and exit.'
  echo '  -p, --packages          Show number of updated packages.'

}

version_message() {
  #
  # Shows version message.
  #
  # Returns:
  #     String message to standard output.
  #
  echo "nanono ${_nanono_ver}"
  echo
  echo 'Copyright (c) 2014 <NAME>'
  echo 'MIT License (http://opensource.org/licenses/MIT)'
}

default_message() {
  #
  # Shows percent message.
  #
  # Returns:
  #     String message to standard output.
  #
  get_packages
  packages=$?
  printf " -> %s packages need to be updated\n" ${packages}

}


#
#   FUNCTIONS
#

get_packages() {
  #
  # Get number of updated packages.
  #
  # Returns:
  #     An integer with number of updated packages.
  #
  packages=$( checkupdates | wc -l )
  return ${packages}
}

parse_args() {
  #
  # Parses script parameters.
  #
  # Arguments:
  #     params (str) - Script params.
  #
  # Returns:
  #     String message or nothing.
  #
  arg_num=$#
  if [ ${arg_num} -eq 0 ]; then
    default_message 
    exit 0

  else
    for arg in "$@"; do
      case "${arg}" in
        -h|--help)
          help_message
          exit 0
        ;;

        -V|--version)
          version_message
          exit 0
        ;;

        -p|--packages)
          get_packages
          echo "$?"
        ;;

        -*)
          echo "nanono: invalid option '$1'" 1>&2
          echo "Try '-h' or '--help' for more information." 1>&2
          exit 64  # command line usage error (via /usr/include/sysexits.h)
        ;;<commit_msg>Battery capacity in percents<commit_after>#!/bin/sh
#
# nanono - Nano notifications for Linux.
#
# https://github.com/macie/nanono
#
# Copyright (c) 2014 <NAME> <<EMAIL>>
# MIT License (http://opensource.org/licenses/MIT)


#
#   DEFAULTS
#

readonly _nanono_ver='0.2.0'


#
#   MESSAGES
#

help_message() {
  #
  # Shows help message.
  #
  # Returns:
  #     String message to standard output.
  #
  echo 'nanono - Nano notifications for Linux.'
  echo 'Usage:'
  echo '  nanono.sh [options]'
  echo 
  echo 'Options:'
  echo '  -h, --help              Show this help and exit.'
  echo '  -V, --version           Show version number and exit.'
  echo '  -b, --battery           Show battery capacity (in percents).'
  echo '  -p, --packages          Show number of updated packages.'

}

version_message() {
  #
  # Shows version message.
  #
  # Returns:
  #     String message to standard output.
  #
  echo "nanono ${_nanono_ver}"
  echo
  echo 'Copyright (c) 2014 <NAME>'
  echo 'MIT License (http://opensource.org/licenses/MIT)'
}

default_message() {
  #
  # Shows percent message.
  #
  # Returns:
  #     String message to standard output.
  #
  get_battery
  battery=$?
  printf " -> battery has %s%% capacity\n" ${battery}

  get_packages
  packages=$?
  printf " -> %s packages need to be updated\n" ${packages}

}


#
#   FUNCTIONS
#

get_battery() {
  #
  # Get battery capacity (in percents).
  #
  # Returns:
  #     An integer with battery capacity (in percents).
  #
  capacity="$(cat /sys/class/power_supply/BAT0/capacity)"
  return ${capacity}
}

get_packages() {
  #
  # Get number of updated packages.
  #
  # Returns:
  #     An integer with number of updated packages.
  #
  packages=$( checkupdates | wc -l )
  return ${packages}
}

parse_args() {
  #
  # Parses script parameters.
  #
  # Arguments:
  #     params (str) - Script params.
  #
  # Returns:
  #     String message or nothing.
  #
  arg_num=$#
  if [ ${arg_num} -eq 0 ]; then
    default_message 
    exit 0

  else
    for arg in "$@"; do
      case "${arg}" in
        -h|--help)
          help_message
          exit 0
        ;;

        -V|--version)
          version_message
          exit 0
        ;;

        -b|--battery)
          get_battery
          echo "$?"
        ;;

        -p|--packages)
          get_packages
          echo "$?"
        ;;

        -*)
          echo "nanono: invalid option '$1'" 1>&2
          echo "Try '-h' or '--help' for more information." 1>&2
          exit 64  # command line usage error (via /usr/include/sysexits.h)
        ;;
{'fraction_non_alphanumeric': 0.13334760273972604, 'fraction_numerical': 0.009631849315068493, 'mean_word_length': 1.9840357598978289, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 18, 'https://': 2, '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': '6358614', 'n_tokens_mistral': 1647, 'n_tokens_neox': 1563, 'n_words': 432}