svn commit: r210089 - head/games/pom

Ed Maste emaste at FreeBSD.org
Thu Jul 15 00:16:05 UTC 2010


Author: emaste
Date: Thu Jul 15 00:16:04 2010
New Revision: 210089
URL: http://svn.freebsd.org/changeset/base/210089

Log:
  Add -p option to have pom(6) print just the percentage, without extra text.
  
  PR:		bin/51070
  Submitted by:	Matt Koivisto mkoivisto sandvine com
  MFC after:	1 week

Modified:
  head/games/pom/pom.6
  head/games/pom/pom.c

Modified: head/games/pom/pom.6
==============================================================================
--- head/games/pom/pom.6	Thu Jul 15 00:04:14 2010	(r210088)
+++ head/games/pom/pom.6	Thu Jul 15 00:16:04 2010	(r210089)
@@ -32,7 +32,7 @@
 .\"	@(#)pom.6	8.1 (Berkeley) 5/31/93
 .\" $FreeBSD$
 .\"
-.Dd May 31, 1993
+.Dd July 14, 2010
 .Dt POM 6
 .Os
 .Sh NAME
@@ -40,6 +40,7 @@
 .Nd display the phase of the moon
 .Sh SYNOPSIS
 .Nm 
+.Op Fl p
 .Op Fl d Ar yyyy.mm.dd
 .Op Fl t Ar hh:mm:ss
 .Sh DESCRIPTION
@@ -49,6 +50,10 @@ utility displays the current phase of th
 Useful for selecting software completion target dates and predicting
 managerial behavior.
 .Pp
+Use the
+.Fl p
+option to print just the phase as a percentage.
+.Pp
 Use the arguments
 .Fl d
 and

Modified: head/games/pom/pom.c
==============================================================================
--- head/games/pom/pom.c	Thu Jul 15 00:04:14 2010	(r210088)
+++ head/games/pom/pom.c	Thu Jul 15 00:16:04 2010	(r210089)
@@ -84,14 +84,17 @@ main(int argc, char **argv)
 	time_t tt;
 	struct tm GMT, tmd;
 	double days, today, tomorrow;
-	int ch, cnt;
+	int ch, cnt, pflag = 0;
 	char *odate = NULL, *otime = NULL;
 
-	while ((ch = getopt(argc, argv, "d:t:")) != -1)
+	while ((ch = getopt(argc, argv, "d:pt:")) != -1)
 		switch (ch) {
 		case 'd':
 			odate = optarg;
 			break;
+		case 'p':
+			pflag = 1;
+			break;
 		case 't':
 			otime = optarg;
 			break;
@@ -134,6 +137,10 @@ main(int argc, char **argv)
 	for (cnt = EPOCH; cnt < GMT.tm_year; ++cnt)
 		days += isleap(1900 + cnt) ? 366 : 365;
 	today = potm(days) + .5;
+	if (pflag) {
+		(void)printf("%1.0f\n", today);
+		return (0);
+	}
 	(void)printf("The Moon is ");
 	if ((int)today == 100)
 		(void)printf("Full\n");
@@ -227,6 +234,7 @@ static void
 usage(char *progname)
 {
 
-	fprintf(stderr, "Usage: %s [-d yyyy.mm.dd] [-t hh:mm:ss]\n", progname);
+	fprintf(stderr, "Usage: %s [-p] [-d yyyy.mm.dd] [-t hh:mm:ss]\n",
+	    progname);
 	exit(EX_USAGE);
 }


More information about the svn-src-head mailing list