private static String sayOrThink(final String[] args, final boolean think) {
		try {
			boolean isThought = think;

			String wordwrap = null;
			CommandLine commandLine = CowsayCli.parseCmdArgs(args);
			if (commandLine != null) {
				if (commandLine.hasOption(CowsayCli.Opt.HELP.toString())) {
					CowsayCli.showCmdLineHelp();
				}
				else if (commandLine.hasOption(CowsayCli.Opt.LIST_COWS.toString())) {
					String[] files = Cowloader.listAllCowfiles();
					if (files != null) {
						return StringUtils.join(files, System.getProperty("line.separator"));
					}
				}
				else {
					String cowfileSpec = null;
					CowFace cowFace = null;

					if (commandLine.hasOption(CowsayCli.Opt.WRAP_AT.toString())) {
						wordwrap = commandLine.getOptionValue(CowsayCli.Opt.WRAP_AT.toString());
					}
					else if (commandLine.hasOption(CowsayCli.Opt.NOWRAP.toString())) {
						wordwrap = "0";
					}
					cowFace = getCowFaceByMode(commandLine);
					if (cowFace == null) {
						// if we are in here no modes were set
						if (commandLine.hasOption(CowsayCli.Opt.COWFILE.toString())) {
							cowfileSpec = commandLine.getOptionValue(CowsayCli.Opt.COWFILE.toString());
						}
						cowFace = getCowFace(commandLine);
					}

					if (commandLine.hasOption(CowsayCli.Opt.THINK.toString())) {
						isThought = true;
					}

					if (cowfileSpec == null) {
						cowfileSpec = Cowloader.DEFAULT_COW;
					}

					String cowTemplate = Cowloader.load(cowfileSpec);
					if (cowTemplate != null) {
						String moosages[] = commandLine.getArgs();
						String moosage = StringUtils.join(moosages, " ");
						if (moosage != null && moosage.length() > 0) {
							Message message = new Message(moosage, isThought);
							if (wordwrap != null) {
								message.setWordwrap(wordwrap);
							}
							String cow = CowFormatter.formatCow(cowTemplate, cowFace, message);
							cow = formatHtml(commandLine, cow, moosage, isThought);
							return cow;
						}
					}
				}
			}
		}
		catch (CowParseException ex) {
			Logger.getLogger(Cowsay.class.getName()).log(Level.SEVERE, null, ex);
		}
		return "";
	}
private static String sayOrThink(final String[] args, final boolean think) {
		try {
			boolean isThought = think;

			String wordwrap = null;
			CommandLine commandLine = CowsayCli.parseCmdArgs(args);
			if (commandLine != null) {
				if (commandLine.hasOption(CowsayCli.Opt.HELP.toString())) {
					CowsayCli.showCmdLineHelp();
				}
				else if (commandLine.hasOption(CowsayCli.Opt.LIST_COWS.toString())) {
					String[] files = Cowloader.listAllCowfiles();
					if (files != null) {
						return StringUtils.join(files, System.getProperty("line.separator"));
					}
				}
				else {
					String cowfileSpec = null;
					CowFace cowFace = null;

					if (commandLine.hasOption(CowsayCli.Opt.WRAP_AT.toString())) {
						wordwrap = commandLine.getOptionValue(CowsayCli.Opt.WRAP_AT.toString());
					}
					else if (commandLine.hasOption(CowsayCli.Opt.NOWRAP.toString())) {
						wordwrap = "0";
					}
					cowFace = getCowFaceByMode(commandLine);
					if (cowFace == null) {
						
						if (commandLine.hasOption(CowsayCli.Opt.COWFILE.toString())) {
							cowfileSpec = commandLine.getOptionValue(CowsayCli.Opt.COWFILE.toString());
						}
						cowFace = getCowFace(commandLine);
					}

					if (commandLine.hasOption(CowsayCli.Opt.THINK.toString())) {
						isThought = true;
					}

					if (cowfileSpec == null) {
						cowfileSpec = Cowloader.DEFAULT_COW;
					}

					String cowTemplate = Cowloader.load(cowfileSpec);
					if (cowTemplate != null) {
						String moosages[] = commandLine.getArgs();
						String moosage = StringUtils.join(moosages, " ");
						if (moosage != null && moosage.length() > 0) {
							Message message = new Message(moosage, isThought);
							if (wordwrap != null) {
								message.setWordwrap(wordwrap);
							}
							String cow = CowFormatter.formatCow(cowTemplate, cowFace, message);
							cow = formatHtml(commandLine, cow, moosage, isThought);
							return cow;
						}
					}
				}
			}
		}
		catch (CowParseException ex) {
			Logger.getLogger(Cowsay.class.getName()).log(Level.SEVERE, null, ex);
		}
		return "";
	}
private static String sayOrThink ( final String [ ] args , final boolean think ) { try { boolean isThought = think ; String wordwrap = null ; CommandLine commandLine = CowsayCli . parseCmdArgs ( args ) ; if ( commandLine != null ) { if ( commandLine . hasOption ( CowsayCli . Opt . HELP . toString ( ) ) ) { CowsayCli . showCmdLineHelp ( ) ; } else if ( commandLine . hasOption ( CowsayCli . Opt . LIST_COWS . toString ( ) ) ) { String [ ] files = Cowloader . listAllCowfiles ( ) ; if ( files != null ) { return StringUtils . join ( files , System . getProperty ( "line.separator" ) ) ; } } else { String cowfileSpec = null ; CowFace cowFace = null ; if ( commandLine . hasOption ( CowsayCli . Opt . WRAP_AT . toString ( ) ) ) { wordwrap = commandLine . getOptionValue ( CowsayCli . Opt . WRAP_AT . toString ( ) ) ; } else if ( commandLine . hasOption ( CowsayCli . Opt . NOWRAP . toString ( ) ) ) { wordwrap = "0" ; } cowFace = getCowFaceByMode ( commandLine ) ; if ( cowFace == null ) { // if we are in here no modes were set if ( commandLine . hasOption ( CowsayCli . Opt . COWFILE . toString ( ) ) ) { cowfileSpec = commandLine . getOptionValue ( CowsayCli . Opt . COWFILE . toString ( ) ) ; } cowFace = getCowFace ( commandLine ) ; } if ( commandLine . hasOption ( CowsayCli . Opt . THINK . toString ( ) ) ) { isThought = true ; } if ( cowfileSpec == null ) { cowfileSpec = Cowloader . DEFAULT_COW ; } String cowTemplate = Cowloader . load ( cowfileSpec ) ; if ( cowTemplate != null ) { String moosages [ ] = commandLine . getArgs ( ) ; String moosage = StringUtils . join ( moosages , " " ) ; if ( moosage != null && moosage . length ( ) > 0 ) { Message message = new Message ( moosage , isThought ) ; if ( wordwrap != null ) { message . setWordwrap ( wordwrap ) ; } String cow = CowFormatter . formatCow ( cowTemplate , cowFace , message ) ; cow = formatHtml ( commandLine , cow , moosage , isThought ) ; return cow ; } } } } } catch ( CowParseException ex ) { Logger . getLogger ( Cowsay . class . getName ( ) ) . log ( Level . SEVERE , null , ex ) ; } return "" ; }
Do some cowsaying or cowthinking.
@param args the command line arguments
@param think if true will think instead of say (the --cowthink flag can also invoke thinking)
Do some cowsaying or cowthinking .