Files
gitx/Commands/PBStashCommandFactory.m
T
2010-11-06 13:20:13 +01:00

47 lines
1.6 KiB
Objective-C

//
// PBStashCommandFactory.m
// GitX
//
// Created by Tomasz Krasnyk on 10-11-06.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//
#import "PBStashCommandFactory.h"
#import "PBStashCommand.h"
// model
#import "PBGitStash.h"
@implementation PBStashCommandFactory
+ (NSArray *) commandsForObject:(NSObject *) object repository:(PBGitRepository *) repository {
if (![object isKindOfClass:[PBGitStash class]]) {
return nil;
}
PBGitStash *stash = (PBGitStash *) object;
NSMutableArray *commands = [[NSMutableArray alloc] init];
NSArray *args = [NSArray arrayWithObjects:@"apply", [stash name], nil];
PBStashCommand *command = [[PBStashCommand alloc] initWithDisplayName:@"Apply" arguments:args repository:repository];
command.commandTitle = command.displayName;
command.commandDescription = [NSString stringWithFormat:@"Applying stash: '%@'", stash];
[commands addObject:command];
args = [NSArray arrayWithObjects:@"pop", [stash name], nil];
command = [[PBStashCommand alloc] initWithDisplayName:@"Pop" arguments:args repository:repository];
command.commandTitle = command.displayName;
command.commandDescription = [NSString stringWithFormat:@"Poping stash: '%@'", stash];
[commands addObject:command];
args = [NSArray arrayWithObjects:@"drop", [stash name], nil];
command = [[PBStashCommand alloc] initWithDisplayName:@"Drop" arguments:args repository:repository];
command.commandTitle = command.displayName;
command.commandDescription = [NSString stringWithFormat:@"Dropping stash: '%@'", stash];
[commands addObject:command];
return [commands autorelease];
}
@end