Skip to content

Latest commit

 

History

History
120 lines (90 loc) · 2.87 KB

README.md

File metadata and controls

120 lines (90 loc) · 2.87 KB

Exercise (RegexInFiles)

RegexInFiles helps to search regex in text files, using parameters from user(cli) or directly from another test module (TestClass)

Install

make build-image

Requirements

  • bash
  • make
  • docker
  • git

Usage

There's a MakeFile with 5 pre-configured methods (build-image, tests-run, tests-run-verbose, app_runner, run-interactive)

Basic Use

There's a several options to use this app, all of them including the use of docker.io:

First step - create a docker image:
# make build-image

running tests:


# make tests-run
tests-run will run all tests written in pytest folder from given container then docker will remove the container

tests-run-verbose:


# make tests-run-verbose
tests-run-verbose will run all tests written in pytest folder including verbose from given container then docker will remove the container

app_runner:


# make app_runner

app_runner will run basic functionality of RegexInFiles app on the created container with optional files / regex

  • running 'make app_runner' without any files or regex will run default values (FILE=Exercise/pytest/example1.txt, REGEX=grows)

Example to use external files\regex:
# make app_runner FILE=/your_dir_path/your_file.txt REGEX=your_regex

run-interactive:


# make run-interactive

run-interactive will generate container in interactive mode, in this mode you'll enter to ubuntu 14.04 container including the 'Exercise' repository (mounted).
Basic Example(from container bash, without using pytest):
# python3 Exercise/run_app.py -c -f ./Exercise/pytest/example1.txt -r grows
-c & -m is mutually exclusive parameters
-f & -r is a required parameters & Unique (not support several appearanses)

General help:


usage:
This application is designed to search for regex matches in text files
[-h] -f FILES -r REGEX [-c | -m]

RegexInFiles

optional arguments:

-h, --help show this help message and exit
-f FILES, --files FILES
This is the files flag - **required flag
-r REGEX, --regex REGEX
This is the regex flag - **required flag
-c, --color This is the color flag
-m, --machine This is the machine readable output flag



Example of use: python run_app.py -c -f "./pytest/example1.txt" -r grows

Example of output:

example1.txt:2:2020-06-28 15:10:00.382291:Banana grows on trees


example1.txt:3:2020-06-28 15:10:00.383258:Coconut grows on trees

  • BTW - inside scatches dir there's a module that I create to parse parameters from CLI, later I understand argparse module is a better solution.