1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-18 13:54:36 -05:00

Add -rasi-validate option.

Issue: #1260
This commit is contained in:
Dave Davenport 2021-01-26 17:27:32 +01:00
parent 8999d94850
commit 01935064d8
4 changed files with 49 additions and 0 deletions

View file

@ -215,6 +215,12 @@ Dump the current active theme, in rasi format, to stdout and exit.
Dump the current active configuration, in Xresources format, to stdout. Dump the current active configuration, in Xresources format, to stdout.
This does not validate all passed values (for example, colors). This does not validate all passed values (for example, colors).
.PP
\fB\fC\-rasi\-validate\fR \fIfilename\fP
.PP
Try to parse the file and 0 when succesful.
.PP .PP
\fB\fC\-threads\fR \fInum\fP \fB\fC\-threads\fR \fInum\fP

View file

@ -128,6 +128,10 @@ Dump the current active theme, in rasi format, to stdout and exit.
Dump the current active configuration, in Xresources format, to stdout. Dump the current active configuration, in Xresources format, to stdout.
This does not validate all passed values (for example, colors). This does not validate all passed values (for example, colors).
`-rasi-validate` *filename*
Try to parse the file and 0 when succesful.
`-threads` *num* `-threads` *num*
Specify the number of threads **rofi** should use: Specify the number of threads **rofi** should use:

View file

@ -387,4 +387,12 @@ void rofi_theme_parse_merge_widgets ( ThemeWidget *parent, ThemeWidget *child );
*/ */
ThemeMediaType rofi_theme_parse_media_type ( const char *type ); ThemeMediaType rofi_theme_parse_media_type ( const char *type );
RofiDistance rofi_theme_property_copy_distance ( RofiDistance const distance ); RofiDistance rofi_theme_property_copy_distance ( RofiDistance const distance );
/**
* @param filename The file to validate.
*
* @returns the program exit code.
*/
int rofi_theme_rasi_validate ( const char *filename );
#endif #endif

View file

@ -796,6 +796,19 @@ int main ( int argc, char *argv[] )
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
if ( find_arg ( "-rasi-validate" ) >= 0 ) {
char *str = NULL;
find_arg_str ( "-rasi-validate", &str );
if ( str != NULL ) {
int retv = rofi_theme_rasi_validate ( str );
cleanup ();
return retv;
}
fprintf ( stderr, "Usage: %s -rasi-validate my-theme.rasi", argv[0] );
return EXIT_FAILURE;
}
{ {
const char *ro_pid = g_getenv ( "ROFI_OUTSIDE" ); const char *ro_pid = g_getenv ( "ROFI_OUTSIDE" );
if ( ro_pid != NULL ) { if ( ro_pid != NULL ) {
@ -1158,3 +1171,21 @@ int main ( int argc, char *argv[] )
g_free ( windowid ); g_free ( windowid );
return return_code; return return_code;
} }
/** List of error messages.*/
extern GList *list_of_error_msgs;
int rofi_theme_rasi_validate ( const char *filename )
{
rofi_theme_parse_file ( filename );
if ( list_of_error_msgs == NULL ) {
return EXIT_SUCCESS;
}
for ( GList *iter = g_list_first ( list_of_error_msgs );
iter != NULL; iter = g_list_next ( iter ) ) {
fputs ( ((GString*)iter->data)->str, stderr );
}
return EXIT_FAILURE;
}