#!/bin/sh

# Copyright (C) 2002, 2003 Simon Baldwin (simonb@sco.com)
# Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
#               2011, 2012, 2013, 2014, 2016, 2017, 2018, 2019
#               2020 Felix Natter
# Copyright (C) 2021, 2022, 2023 Felix Natter, Mihai Gătejescu

# Author: Michael Opdenacker <michaelo@gnu.org> 2002-08-05

# This file if a part of GNU Typist

# GNU Typist 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.

# GNU Typist 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.

# You should have received a copy of the GNU General Public License
# along with GNU Typist.  If not, see <http://www.gnu.org/licenses/>.

case "$1" in
   "")
	echo "You must specify the letters you want"
	echo "as the first argument. Try --help."
	;;
   "--help")
	echo "Usage: ./findwords.sh letters [combination]"
	echo
	echo "This is a simple script to help you find words"
	echo "which contain only specified letters and/or have"
	echo "some special combination of letters in them."
	echo
	echo "You can use '.' to match all the letters"
	;;
   ".")
	aspell dump master | grep -v [\'] | grep "$2"
	;;
   *)
	aspell dump master | grep -w ^[${1}]* | grep -v [\'] | grep "$2"
	;;
esac

