cinera.c: Add -q flag
This sets cinera to "oneshot mode" which makes a Project Edition instance quit after syncing from annotation files in project input directory
This commit is contained in:
parent
1bbdf5aea4
commit
4a954b6ac6
|
@ -14,7 +14,7 @@ typedef struct
|
|||
version CINERA_APP_VERSION = {
|
||||
.Major = 0,
|
||||
.Minor = 5,
|
||||
.Patch = 11
|
||||
.Patch = 12
|
||||
};
|
||||
|
||||
#define CINERA_DB_VERSION 2
|
||||
|
@ -69,7 +69,8 @@ enum
|
|||
enum
|
||||
{
|
||||
MODE_BARE,
|
||||
MODE_INTEGRATE
|
||||
MODE_INTEGRATE,
|
||||
MODE_ONESHOT
|
||||
} modes;
|
||||
|
||||
enum
|
||||
|
@ -1694,6 +1695,9 @@ PrintUsage(char *BinaryLocation, config *DefaultConfig)
|
|||
"\n"
|
||||
" -p <project ID>\n"
|
||||
" Set the project ID, corresponding to the \"project\" field in the HMML files\n"
|
||||
" -q\n"
|
||||
" Quit after syncing with annotation files in project input directory\n"
|
||||
" (Only affects PROJECT edition)\n"
|
||||
" -s <style>\n"
|
||||
" Set the style / theme, corresponding to a cinera__*.css file\n"
|
||||
" This is equal to the \"project\" field in the HMML files by default\n"
|
||||
|
@ -2281,6 +2285,7 @@ HMMLToBuffers(buffers *CollationBuffers, char *Filename)
|
|||
break;
|
||||
case RC_ERROR_FILE:
|
||||
case RC_ERROR_MEMORY:
|
||||
hmml_free(&HMML);
|
||||
return RC_ERROR_FATAL;
|
||||
};
|
||||
if(!HasFilterMenu)
|
||||
|
@ -2542,6 +2547,7 @@ AppendedIdentifier:
|
|||
break;
|
||||
case RC_ERROR_FILE:
|
||||
case RC_ERROR_MEMORY:
|
||||
hmml_free(&HMML);
|
||||
return RC_ERROR_FATAL;
|
||||
};
|
||||
if(!HasFilterMenu)
|
||||
|
@ -3880,6 +3886,8 @@ IndexToBuffer(buffers *CollationBuffers)
|
|||
if(!ProjectFound)
|
||||
{
|
||||
fprintf(stderr, "Missing Project Info for %s\n", Config.ProjectID);
|
||||
FreeBuffer(&Index.Metadata.Buffer);
|
||||
FreeBuffer(&Index.File.Buffer);
|
||||
return RC_ERROR_PROJECT;
|
||||
}
|
||||
|
||||
|
@ -3934,6 +3942,8 @@ IndexToBuffer(buffers *CollationBuffers)
|
|||
CollationBuffers->Index.Size = StringLength(queryContainer) + (Index.Header.EntryCount * EntryLength) + StringLength(Script);
|
||||
if(!(CollationBuffers->Index.Location = malloc(CollationBuffers->Index.Size)))
|
||||
{
|
||||
FreeBuffer(&Index.Metadata.Buffer);
|
||||
FreeBuffer(&Index.File.Buffer);
|
||||
return(RC_ERROR_MEMORY);
|
||||
}
|
||||
CollationBuffers->Index.Ptr = CollationBuffers->Index.Location;
|
||||
|
@ -4001,6 +4011,7 @@ IndexToBuffer(buffers *CollationBuffers)
|
|||
CopyStringToBuffer(&CollationBuffers->Index, Script);
|
||||
|
||||
FreeBuffer(&Index.Metadata.Buffer);
|
||||
FreeBuffer(&Index.File.Buffer);
|
||||
return RC_SUCCESS;
|
||||
}
|
||||
else
|
||||
|
@ -4544,7 +4555,7 @@ main(int ArgC, char **Args)
|
|||
}
|
||||
|
||||
char CommandLineArg;
|
||||
while((CommandLineArg = getopt(ArgC, Args, "a:b:B:c:d:fhi:j:l:m:n:o:p:r:R:s:t:U:vx:")) != -1)
|
||||
while((CommandLineArg = getopt(ArgC, Args, "a:b:B:c:d:fhi:j:l:m:n:o:p:qr:R:s:t:U:vx:")) != -1)
|
||||
{
|
||||
switch(CommandLineArg)
|
||||
{
|
||||
|
@ -4589,6 +4600,9 @@ main(int ArgC, char **Args)
|
|||
case 'p':
|
||||
Config.ProjectID = optarg;
|
||||
break;
|
||||
case 'q':
|
||||
Config.Mode = MODE_ONESHOT;
|
||||
break;
|
||||
case 'r':
|
||||
Config.RootDir = StripTrailingSlash(optarg);
|
||||
break;
|
||||
|
@ -4821,6 +4835,10 @@ main(int ArgC, char **Args)
|
|||
|
||||
printf("┌╼ Synchronising with annotation files in Project Input Directory ╾┐\n");
|
||||
SyncIndexWithInput(&CollationBuffers, IndexTemplate, PlayerTemplate);
|
||||
if(Config.Mode == MODE_ONESHOT)
|
||||
{
|
||||
goto RIP;
|
||||
}
|
||||
|
||||
printf("\n┌╼ Monitoring Project Directory for \e[1;32mnew\e[0m, \e[1;33medited\e[0m and \e[1;30mdeleted\e[0m .hmml files ╾┐\n");
|
||||
int inotifyInstance = inotify_init1(IN_NONBLOCK);
|
||||
|
|
Loading…
Reference in New Issue