Skip to content

Check if a hay[stack] contains a [needle] in the command line with some options.

License

Notifications You must be signed in to change notification settings

Lateralus138/contains

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

contains

Top Logo


Description

Check if a hay[stack] contains a [needle] in the command line with some options.

Disclaimer

Nothing new here, just a different way to do it.

Motivation

I just like to build tools the way I want them to work. If this works well for you then that's great and I hope you get god use of it.


Usage

Environment

This is a command line tool that should work in any shell/terminal/console/tty in several operating systems.

Installation

This is a portable application with no dependencies, but the Linux version has a deb package installer that provides simple Bash Completion and some icons for hicolor. If it is not installed it should be placed in your PATH in your respective environment. if you don't put in a PATH then you will have to run it directly, of course.

Your PATH's can be found in your respective variables per your operating system (of course, you might've added your own directories to the PATH:

Linux, Android, and Mac OS Path

echo $PATH
# or
printf '%s\n' $PATH

Windows Path

PowerShell

Write-Host $Env:PATH

CMD

echo %PATH%

Examples

This is a very simple program that accepts a -h, --help switch and strings of of characters and is used the same way regardless of which environment you're in.

Windows Examples

PowerShell:

# Not in path
& 'C:\Path\To\contains.exe' --needle 'World' --haystack 'Hello World' &&
>> Write-Host True ||
>> Write-Host False
True
# In path
contains -n "World" -s "Hello, You" &&
>> Write-Host True ||
>> Write-Host False
False
# Get character position
contains -n 'b' -s 'abc' --position
2

Everything Else Examples

# Not in path
 $ /path/to/contains -n PM -s "$(date)" &&
 > printf '%s\n' "Good afternoon." ||
 > printf '%s\n' "Good morning."
Good afternoon.
# In path
contains -n AM -s "$(date)" &&
 > printf '%s\n' "Good afternoon." ||
 > printf '%s\n' "Good morning."
Good morning.

Help Screen

contains --help
                                                  
 'contains' - Check if a hay[stack] contains a    
 [needle]. This can either return an EXIT_CODE    
 (0 or 1) on found or not or it can PRINT a       
 positional start integer with the 'position'     
 switch.                                          
                                                  
 USAGE:                                           
     contains <SWITCH [PARAMETER]>...             
     if contains -n needle -s stack; then ... fi  
     contains -n needle -s stack && echo found... 
     contains -n needle -s stack --position       
                                                  
 SWITCH:                                          
     -h, --help          This help message.       
     -n, --needle        What to find. [needle]   
     -s, --haystack      Where to look. [stack]   
     -i, --insensitive   Test is case insensitive.
     -p, --position      PRINT the position of the
                         starting character if    
                         found. This changes the  
                         behavior of the program  
                         printing output rather   
                         than returning an exit   
                         code.                    
                                                  
 PARAMETER:                                       
     needle - String of characters to find.       
     stack -  String of characters to look in.    
                        

Project Information

This project is written in C++.

C++

Readme Card

Description Status
Project Release Date GitHub Release Date
Total downloads for this project GitHub all releases
Complete repository size This Repo Size
Commits in last month GitHub commit activity
Commits in last year GitHub commit activity

Latest Version Status

Description Status Number of Downloads
Latest Release version Release Version GitHub release (latest by date)
Latest Tag version, possible Pre-Release's Tag Version GitHub release (latest by date)

File Information

All current compiled files and the source of this project can be found at this repository in the Releases section under Stable Release and can be found in 32 (X86) and 64 (X64) bit format for Windows and 64 bit otherwise.

You may want to rename any of the provided executables to contains (or contains.exe).

This is the recommended method of download.

CR

You can, of course, build, fork, and/or download the source of this project as per the LICENSE of this project. If you want me to create a build for a different architecture and don't want to do it yourself then just let me know what you need and I'll look into it.

MD5

These MD5 values are evaluated immediately after the build.

Windows X86 MD5

X86 MD5

Windows X64 MD5

X64 MD5

Linux MD5

Linux MD5

Debian MD5

Debian MD5

Android MD5

Android MD5


Media

Logo

A simple little logo I created in Glimpse (new verion of GIMP).

This is in the Windows executables and is installed with the hicolor theme with the Linux .deb installer.

Logo

Screenshot Demos

Help Screen

Demo 1

Demo 2


License Info

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

...

About

Check if a hay[stack] contains a [needle] in the command line with some options.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages