felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r1736023 - in /felix/trunk/gogo/jline/src/main: java/org/apache/felix/gogo/jline/Builtin.java resources/gosh_profile
Date Mon, 21 Mar 2016 16:56:04 GMT
Author: gnodet
Date: Mon Mar 21 16:56:04 2016
New Revision: 1736023

URL: http://svn.apache.org/viewvc?rev=1736023&view=rev
Log:
Add jobs commands help

Modified:
    felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Builtin.java
    felix/trunk/gogo/jline/src/main/resources/gosh_profile

Modified: felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Builtin.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Builtin.java?rev=1736023&r1=1736022&r2=1736023&view=diff
==============================================================================
--- felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Builtin.java (original)
+++ felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Builtin.java Mon Mar
21 16:56:04 2016
@@ -459,6 +459,20 @@ public class Builtin {
     }
 
     public void jobs(CommandSession session, String[] argv) {
+        final String[] usage = {"jobs - list jobs",
+                "Usage: jobs [OPTIONS]",
+                "  -? --help                show help",
+        };
+        Options opt = Options.compile(usage).parse(argv);
+        if (opt.isSet("help")) {
+            opt.usage(System.err);
+            return;
+        }
+        if (!opt.args().isEmpty()) {
+            System.err.println("usage: jobs");
+            session.error(2);
+            return;
+        }
         List<Job> jobs = session.jobs();
         Job current = session.currentJob();
         for (Job job : jobs) {
@@ -470,6 +484,20 @@ public class Builtin {
     }
 
     public void fg(CommandSession session, String[] argv) {
+        final String[] usage = {"fg - put job in foreground",
+                "Usage: fg [OPTIONS] [jobid]",
+                "  -? --help                show help",
+        };
+        Options opt = Options.compile(usage).parse(argv);
+        if (opt.isSet("help")) {
+            opt.usage(System.err);
+            return;
+        }
+        if (opt.args().size() > 1) {
+            System.err.println("usage: fg [jobid]");
+            session.error(2);
+            return;
+        }
         List<Job> jobs = session.jobs();
         Collections.reverse(jobs);
         Job current = session.currentJob();
@@ -480,6 +508,7 @@ public class Builtin {
                 job.foreground();
             } else {
                 System.err.println("fg: no current job");
+                session.error(1);
             }
         } else {
             Job job = jobs.stream().filter(j -> j != current && argv[0].equals(Integer.toString(j.id())))
@@ -488,11 +517,26 @@ public class Builtin {
                 job.foreground();
             } else {
                 System.err.println("fg: job not found: " + argv[0]);
+                session.error(1);
             }
         }
     }
 
     public void bg(CommandSession session, String[] argv) {
+        final String[] usage = {"bg - put job in background",
+                "Usage: bg [OPTIONS] [jobid]",
+                "  -? --help                show help",
+        };
+        Options opt = Options.compile(usage).parse(argv);
+        if (opt.isSet("help")) {
+            opt.usage(System.err);
+            return;
+        }
+        if (opt.args().size() > 1) {
+            System.err.println("usage: bg [jobid]");
+            session.error(2);
+            return;
+        }
         List<Job> jobs = session.jobs();
         Collections.reverse(jobs);
         Job current = session.currentJob();
@@ -502,7 +546,8 @@ public class Builtin {
             if (job != null) {
                 job.background();
             } else {
-                System.err.println("fg: no current job");
+                System.err.println("bg: no current job");
+                session.error(1);
             }
         } else {
             Job job = jobs.stream().filter(j -> j != current && argv[0].equals(Integer.toString(j.id())))
@@ -510,7 +555,8 @@ public class Builtin {
             if (job != null) {
                 job.background();
             } else {
-                System.err.println("fg: job not found: " + argv[0]);
+                System.err.println("bg: job not found: " + argv[0]);
+                session.error(1);
             }
         }
     }

Modified: felix/trunk/gogo/jline/src/main/resources/gosh_profile
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/jline/src/main/resources/gosh_profile?rev=1736023&r1=1736022&r2=1736023&view=diff
==============================================================================
--- felix/trunk/gogo/jline/src/main/resources/gosh_profile (original)
+++ felix/trunk/gogo/jline/src/main/resources/gosh_profile Mon Mar 21 16:56:04 2016
@@ -240,6 +240,15 @@ try {
   complete -c gogo:tmux -e
   complete -c gogo:tmux -d "Terminal multiplexer"
 
+  complete -c gogo:bg -e
+  complete -c gogo:bg -d "Put job in background"
+
+  complete -c gogo:fg -e
+  complete -c gogo:fg -d "Put job in foreground"
+
+  complete -c gogo:jobs -e
+  complete -c gogo:jobs -d "List jobs"
+
   # print welcome message
   cat ($0 resolve motd)
 } {



Mime
View raw message