Revision: 22798
          http://sourceforge.net/p/bibdesk/svn/22798
Author:   hofman
Date:     2018-10-11 13:32:52 +0000 (Thu, 11 Oct 2018)
Log Message:
-----------
combine URL file and relative file commands into single resolve command

Modified Paths:
--------------
    trunk/bibdesk/BDSKFileURLCommand.h
    trunk/bibdesk/BDSKFileURLCommand.m
    trunk/bibdesk/Scripting/BibDesk.sdef

Modified: trunk/bibdesk/BDSKFileURLCommand.h
===================================================================
--- trunk/bibdesk/BDSKFileURLCommand.h  2018-10-11 13:26:28 UTC (rev 22797)
+++ trunk/bibdesk/BDSKFileURLCommand.h  2018-10-11 13:32:52 UTC (rev 22798)
@@ -41,11 +41,8 @@
 @interface BDSKFileURLCommand : NSScriptCommand
 @end
 
-@interface BDSKURLFileCommand : NSScriptCommand
-@end
-
 @interface BDSKRelativePathCommand : NSScriptCommand
 @end
 
-@interface BDSKRelativeFileCommand : NSScriptCommand
+@interface BDSKResolveFileCommand : NSScriptCommand
 @end

Modified: trunk/bibdesk/BDSKFileURLCommand.m
===================================================================
--- trunk/bibdesk/BDSKFileURLCommand.m  2018-10-11 13:26:28 UTC (rev 22797)
+++ trunk/bibdesk/BDSKFileURLCommand.m  2018-10-11 13:32:52 UTC (rev 22798)
@@ -53,25 +53,12 @@
 
 @end
 
-@implementation BDSKURLFileCommand
-
-- (id)performDefaultImplementation  {
-    NSString *fileURL = [self evaluatedReceivers] ?: [self directParameter];
-    if ([fileURL isKindOfClass:[NSString class]] == NO) {
-        [self setScriptErrorNumber:NSArgumentsWrongScriptError];
-        return nil;
-    }
-    return [NSURL URLWithString:fileURL];
-}
-
-@end
-
 @implementation BDSKRelativePathCommand
 
 - (id)performDefaultImplementation  {
     NSDictionary *args = [self evaluatedArguments];
     NSURL *fileURL = [args objectForKey:@"of"];
-    NSURL *baseURL = [args objectForKey:@"from"];
+    NSURL *baseURL = [args objectForKey:@"to"];
     if ([fileURL isKindOfClass:[NSURL class]] == NO || [baseURL 
isKindOfClass:[NSURL class]] == NO) {
         [self setScriptErrorNumber:NSArgumentsWrongScriptError];
         return nil;
@@ -85,13 +72,13 @@
 
 @end
 
-@implementation BDSKRelativeFileCommand
+@implementation BDSKResolveFileCommand
     
 - (id)performDefaultImplementation  {
     NSDictionary *args = [self evaluatedArguments];
     NSString *relativePath = [self evaluatedReceivers] ?: [self 
directParameter];
-    NSURL *baseURL = [args objectForKey:@"from"];
-    if ([relativePath isKindOfClass:[NSString class]] == NO || [baseURL 
isKindOfClass:[NSURL class]] == NO) {
+    NSURL *baseURL = [args objectForKey:@"to"];
+    if ([relativePath isKindOfClass:[NSString class]] == NO || (baseURL && 
[baseURL isKindOfClass:[NSURL class]] == NO)) {
         [self setScriptErrorNumber:NSArgumentsWrongScriptError];
         return nil;
     }
@@ -101,6 +88,10 @@
         return [NSURL URLWithString:relativePath];
     if ([relativePath isAbsolutePath])
         return  [NSURL fileURLWithPath:relativePath];
+    if (baseURL == nil) {
+        [self setScriptErrorNumber:NSRequiredArgumentsMissingScriptError];
+        return nil;
+    }
     BOOL isDir = YES;
     baseURL = [baseURL URLByStandardizingPath];
     if ([[NSFileManager defaultManager] fileExistsAtPath:[baseURL path] 
isDirectory:&isDir] && isDir == NO)

Modified: trunk/bibdesk/Scripting/BibDesk.sdef
===================================================================
--- trunk/bibdesk/Scripting/BibDesk.sdef        2018-10-11 13:26:28 UTC (rev 
22797)
+++ trunk/bibdesk/Scripting/BibDesk.sdef        2018-10-11 13:32:52 UTC (rev 
22798)
@@ -751,13 +751,6 @@
             <result description="The file URL of the file." type="text"/>
         </command>
         
-        <command name="URL file" code="BDSKURLf"
-            description="A file object specified with a file URL.">
-            <cocoa class="BDSKURLFileCommand"/>
-            <direct-parameter type="text" description="The file URL."/>
-            <result description="The file." type="file"/>
-        </command>
-        
         <command name="relative path" code="BDSKrelP"
             description="The relative path for a file from a base file.">
             <cocoa class="BDSKRelativePathCommand"/>
@@ -765,22 +758,22 @@
                 description="The file to get the relative path of.">
                 <cocoa key="of"/>
             </parameter>
-            <parameter name="from" type="file" code="from"
-                description="The base file from which to start the relative 
path. If this exists and is not a directory the path will be relative to the 
containing directory.">
-                <cocoa key="from"/>
+            <parameter name="to" type="file" code="to  "
+                description="A base file the path is relative to. Takes the 
containing directory if this exists and is not a directory.">
+                <cocoa key="to"/>
             </parameter>
             <result description="The relative POSIX path." type="text"/>
         </command>
         
-        <command name="relative file" code="BDSKrelF"
+        <command name="resolve" code="BDSKRslv"
             description="A file given by a relative path from a base file.">
-            <cocoa class="BDSKRelativeFileCommand"/>
-            <direct-parameter type="text" description="The relative POSIX 
path."/>
-            <parameter name="from" type="file" code="from"
-                description="The base file from which to start the relative 
path. If this exists and is not a directory the path will be relative to the 
containing directory.">
-                <cocoa key="from"/>
+            <cocoa class="BDSKReolveCommand"/>
+            <direct-parameter type="text" description="A file URL or relative, 
tilde-abbreviated, or absolute POSIX path."/>
+            <parameter name="relative to" type="file" code="to  " 
optional="yes"
+                description="A base file the path is relative to. Takes the 
containing directory if this exists and is not a directory.">
+                <cocoa key="frtoom"/>
             </parameter>
-            <result description="The file from the relative POSIX path." 
type="file"/>
+            <result description="The file from the path expression." 
type="file"/>
         </command>
         
         <command name="perform BibDesk action with publications" 
code="BDSKpAct"

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
Bibdesk-commit mailing list
Bibdesk-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to