Author: rfm
Date: Tue Jul 21 15:32:22 2015
New Revision: 38818

URL: http://svn.gna.org/viewcvs/gnustep?rev=38818&view=rev
Log:
defaults command added

Modified:
    libs/ec/trunk/EcProcess.h
    libs/ec/trunk/EcProcess.m

Modified: libs/ec/trunk/EcProcess.h
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/ec/trunk/EcProcess.h?rev=38818&r1=38817&r2=38818&view=diff
==============================================================================
--- libs/ec/trunk/EcProcess.h   (original)
+++ libs/ec/trunk/EcProcess.h   Tue Jul 21 15:32:22 2015
@@ -415,10 +415,13 @@
  * If the same default name is registered more than once, the values
  * from the last registration are used, except for the case where the
  * cmd argument is NULL, in that case the previous selector is kept
- * in the new rfegistration.<br />
+ * in the new registration.<br />
  * This method should be called in your +initialize method, so that all
  * supported defaults are already registered by the time your process
- * tries to respond to being started with a --help command line argument.
+ * tries to respond to being started with a --help command line argument.<br />
+ * NB. defaults keys do not have to be registered (and can still be updated
+ * using the 'defaults' command), but registration provides a more user
+ * friendly interface.
  */
 + (void) ecRegisterDefault: (NSString*)name
               withTypeText: (NSString*)type

Modified: libs/ec/trunk/EcProcess.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/ec/trunk/EcProcess.m?rev=38818&r1=38817&r2=38818&view=diff
==============================================================================
--- libs/ec/trunk/EcProcess.m   (original)
+++ libs/ec/trunk/EcProcess.m   Tue Jul 21 15:32:22 2015
@@ -2272,7 +2272,11 @@
 
 - (void) ecNewDay: (NSCalendarDate*)when
 {
-  NSString             *sub;
+  static NSDictionary   *defs = nil;
+  NSString             *sub;
+  NSDictionary          *d;
+  NSEnumerator          *e;
+  NSString              *k;
 
   /* New day ... archive debug/log files into a subdirectory based on
    * the current date.  This is yesterday's debug, so we use yesterday.
@@ -2280,6 +2284,21 @@
   sub = [[when dateByAddingYears: 0 months: 0 days: -1 hours: 0 minutes: 0
     seconds: 0] descriptionWithCalendarFormat: @"%Y-%m-%d"];
   NSLog(@"%@", [self cmdArchive: sub]);
+
+  /* Check information left in the EcCommand domain.
+   */
+  d = [cmdDefs volatileDomainForName: @"EcCommand"];
+  e = [[d allKeys] objectEnumerator];
+  while (nil != (k = [e nextObject]))
+    {
+      if ([[d objectForKey: k] isEqual: [defs objectForKey: k]])
+        {
+         [self cmdError: @"Console defaults '%@' left for over a day."
+            @" Please reset ('tell %@ defaults delete %@') after updating"
+            @" Control.plist as required.", k, [self cmdName], k];
+        }
+    }
+  ASSIGNCOPY(defs, d);
 }
 
 - (void) ecNewHour: (NSCalendarDate*)when
@@ -2955,6 +2974,72 @@
          else
            {
              [self cmdPrintf: @"%@\n", cmdDebugModes];
+           }
+       }
+    }
+}
+
+- (void) cmdMesgdefaults: (NSArray*)msg
+{
+  if ([msg count] == 0)
+    {
+      [self cmdPrintf:
+        @"temporarily overrides defaults/Control.plist settings"];
+    }
+  else
+    {
+      if ([[msg objectAtIndex: 0] caseInsensitiveCompare: @"help"]
+        == NSOrderedSame)
+       {
+         [self cmdPrintf: @"\nWithout parameters, the defaults command is "];
+         [self cmdPrintf: @"used to list the current defaults overrides.\n"];
+         [self cmdPrintf: @"With the 'delete' parameter followed by a name,"];
+         [self cmdPrintf: @"the command is used to revert a default.\n"];
+         [self cmdPrintf: @"With the 'write' parameter followed by a name"];
+         [self cmdPrintf: @"and value, the command sets a default.\n"];
+         [self cmdPrintf: @"With the 'read' parameter followed by a name,"];
+         [self cmdPrintf: @"the command is used to show a default.\n"];
+       }
+      else if ([msg count] > 2)
+       {
+         NSString      *mode = (NSString*)[msg objectAtIndex: 1];
+         NSString      *key = (NSString*)[msg objectAtIndex: 2];
+          id            val;
+
+          if ([mode caseInsensitiveCompare: @"delete"] == NSOrderedSame)
+            {
+              [cmdDefs setCommand: nil forKey: key];
+            }
+          else if ([msg count] > 2
+            && [mode caseInsensitiveCompare: @"set"] == NSOrderedSame)
+           {
+             val = [msg objectAtIndex: 3];
+              [cmdDefs setCommand: val forKey: key];
+           }
+          val = [cmdDefs objectForKey: key];
+          [self cmdPrintf: @"The default setting for '%@' is now\n%@\n", val];
+       }
+      else
+       {
+          NSDictionary  *d = [cmdDefs volatileDomainForName: @"EcCommand"];
+          NSEnumerator  *e = [d keyEnumerator];
+          NSString      *k;
+
+         [self cmdPrintf: @"Console default settings:\n"];
+          k = [e nextObject];
+          if (nil == k)
+            {
+             [self cmdPrintf: @"  None.\n"];
+            }
+          else
+            {
+              while (nil != k)
+                {
+                  id    v = [d objectForKey: k];
+
+                 [self cmdPrintf: @"  %@ = %@\n", k, v];
+                  k = [e nextObject];
+                }
            }
        }
     }


_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs

Reply via email to