diff options
author | emaste <emaste@FreeBSD.org> | 2010-07-15 00:16:04 +0000 |
---|---|---|
committer | emaste <emaste@FreeBSD.org> | 2010-07-15 00:16:04 +0000 |
commit | 5cf2e8608d754524c56bea2a01e94041cdc91dd6 (patch) | |
tree | 8986a36c2c0bcf5beaca2c74215513e1b4ccfe20 /games | |
parent | fc51f07699c12d18c3f565bd7da9ff7eeda0ecde (diff) | |
download | FreeBSD-src-5cf2e8608d754524c56bea2a01e94041cdc91dd6.zip FreeBSD-src-5cf2e8608d754524c56bea2a01e94041cdc91dd6.tar.gz |
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
Diffstat (limited to 'games')
-rw-r--r-- | games/pom/pom.6 | 7 | ||||
-rw-r--r-- | games/pom/pom.c | 14 |
2 files changed, 17 insertions, 4 deletions
diff --git a/games/pom/pom.6 b/games/pom/pom.6 index b77b66b..9043439 100644 --- a/games/pom/pom.6 +++ b/games/pom/pom.6 @@ -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 the moon. 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 diff --git a/games/pom/pom.c b/games/pom/pom.c index 00dacd8..f333bec 100644 --- a/games/pom/pom.c +++ b/games/pom/pom.c @@ -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); } |