Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion App/ProcessMonitor/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

/* GLOBALS */

//'skipAPple' flag
//'skipApple' flag
BOOL skipApple = NO;

//filter string
Expand All @@ -22,6 +22,9 @@ NSString* filterBy = nil;
//'prettyPrint' flag
BOOL prettyPrint = NO;

//'compact' flag
BOOL compact = NO;

//'parseEnv' flag to capture environment variable information
BOOL parseEnv = NO;

Expand Down
10 changes: 9 additions & 1 deletion App/ProcessMonitor/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ BOOL processArgs(NSArray* arguments)

//init 'prettyPrint' flag
prettyPrint = [arguments containsObject:@"-pretty"];

//init 'compact' flag
compact = [arguments containsObject:@"-compact"];

//init 'parseEnv' flag
parseEnv = [arguments containsObject:@"-parseEnv"];
Expand Down Expand Up @@ -136,6 +139,7 @@ void usage()
printf("\n%s (v%s) usage:\n", name.UTF8String, version.UTF8String);
printf(" -h or -help display this usage info\n");
printf(" -pretty JSON output is 'pretty-printed'\n");
printf(" -compact output is printed on a single line imitating a command line invocation\n");
printf(" -skipApple ignore Apple (platform) processes \n");
printf(" -parseEnv parse environment variable information\n");
printf(" -filter <name> show events matching process name\n\n");
Expand Down Expand Up @@ -179,13 +183,17 @@ BOOL monitor()
return;
}
}

//pretty print?
if(YES == prettyPrint)
{
//make me pretty!
printf("%s\n", prettifyJSON(process.description).UTF8String);
}
else if(YES == compact)
{
printf("%s\n", process.compactDescription.UTF8String);
}
else
{
//output
Expand Down
2 changes: 2 additions & 0 deletions Library/Release/ProcessMonitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,6 @@ typedef void (^ProcessCallbackBlock)(Process* _Nonnull);
// flag controls code signing options
-(id _Nullable)init:(es_message_t* _Nonnull)message csOption:(NSUInteger)csOption;

-(NSString* _Nonnull)compactDescription;

@end
11 changes: 11 additions & 0 deletions Library/Source/Process.m
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,17 @@ -(NSString *)description
return description;
}

-(NSString *)compactDescription {
if (self.arguments.count < 1) {
return self.path;
}

NSArray<NSString*>* arguments = @[self.path];
arguments = [arguments arrayByAddingObjectsFromArray:
[self.arguments subarrayWithRange:NSMakeRange(1, self.arguments.count - 1)]];
return [arguments componentsJoinedByString:@" "];
}

@end

//helper function
Expand Down
2 changes: 2 additions & 0 deletions Library/Source/ProcessMonitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,6 @@ typedef void (^ProcessCallbackBlock)(Process* _Nonnull);
// flag controls code signing options
-(id _Nullable)init:(es_message_t* _Nonnull)message csOption:(NSUInteger)csOption parseEnv:(BOOL)parseEnv;

-(NSString* _Nonnull)compactDescription;

@end