-/* Copyright (C) 2014 by Jacob Alexander
+/* Copyright (C) 2014-2015 by Jacob Alexander
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
// ----- Variables -----
// Basic command dictionary
-char* basicCLIDictName = "General Commands";
-CLIDictItem basicCLIDict[] = {
- { "cliDebug", "Enables/Disables hex output of the most recent cli input.", cliFunc_cliDebug },
- { "help", "You're looking at it :P", cliFunc_help },
- { "led", "Enables/Disables indicator LED. Try a couple times just in case the LED is in an odd state.\r\n\t\t\033[33mWarning\033[0m: May adversely affect some modules...", cliFunc_led },
- { "reload", "Signals microcontroller to reflash/reload.", cliFunc_reload },
- { "reset", "Resets the terminal back to initial settings.", cliFunc_reset },
- { "restart", "Sends a software restart, should be similar to powering on the device.", cliFunc_restart },
- { "version", "Version information about this firmware.", cliFunc_version },
+CLIDict_Entry( cliDebug, "Enables/Disables hex output of the most recent cli input." );
+CLIDict_Entry( help, "You're looking at it :P" );
+CLIDict_Entry( led, "Enables/Disables indicator LED. Try a couple times just in case the LED is in an odd state.\r\n\t\t\033[33mWarning\033[0m: May adversely affect some modules..." );
+CLIDict_Entry( reload, "Signals microcontroller to reflash/reload." );
+CLIDict_Entry( reset, "Resets the terminal back to initial settings." );
+CLIDict_Entry( restart, "Sends a software restart, should be similar to powering on the device." );
+CLIDict_Entry( version, "Version information about this firmware." );
+
+CLIDict_Def( basicCLIDict, "General Commands" ) = {
+ CLIDict_Item( cliDebug ),
+ CLIDict_Item( help ),
+ CLIDict_Item( led ),
+ CLIDict_Item( reload ),
+ CLIDict_Item( reset ),
+ CLIDict_Item( restart ),
+ CLIDict_Item( version ),
{ 0, 0, 0 } // Null entry for dictionary end
};
for ( uint8_t cmd = 0; CLIDict[dict][cmd].name != 0; cmd++ )
{
// Compare the first argument and each command entry
- if ( eqStr( cmdPtr, CLIDict[dict][cmd].name ) == -1 )
+ if ( eqStr( cmdPtr, (char*)CLIDict[dict][cmd].name ) == -1 )
{
// Run the specified command function pointer
// argPtr is already pointing at the first character of the arguments
- (*CLIDict[dict][cmd].function)( argPtr );
+ (*(void (*)(char*))CLIDict[dict][cmd].function)( argPtr );
return;
}
}
// Registers a command dictionary with the CLI
-void CLI_registerDictionary( CLIDictItem *cmdDict, char* dictName )
+void CLI_registerDictionary( const CLIDictItem *cmdDict, const char* dictName )
{
// Make sure this max limit of dictionaries hasn't been reached
if ( CLIDictionariesUsed >= CLIMaxDictionaries )
}
// Add dictionary
- CLIDictNames[CLIDictionariesUsed] = dictName;
- CLIDict[CLIDictionariesUsed++] = cmdDict;
+ CLIDictNames[CLIDictionariesUsed] = (char*)dictName;
+ CLIDict[CLIDictionariesUsed++] = (CLIDictItem*)cmdDict;
}
inline void CLI_tabCompletion()
// NOTE: To save on processing, we only care about the commands and ignore the arguments
// If there are arguments, and a valid tab match is found, buffer is cleared (args lost)
// Also ignores full matches
- if ( eqStr( cmdPtr, CLIDict[dict][cmd].name ) == 0 )
+ if ( eqStr( cmdPtr, (char*)CLIDict[dict][cmd].name ) == 0 )
{
// TODO Make list of commands if multiple matches
matches++;
- tabMatch = CLIDict[dict][cmd].name;
+ tabMatch = (char*)CLIDict[dict][cmd].name;
}
}
}
for ( uint8_t dict = 0; dict < CLIDictionariesUsed; dict++ )
{
// Print the name of each dictionary as a title
- dPrintStrsNL( NL, "\033[1;32m", CLIDictNames[dict], "\033[0m" );
+ print( NL "\033[1;32m" );
+ _print( CLIDictNames[dict] ); // This print is requride by AVR (flash)
+ print( "\033[0m" NL );
// Parse each cmd/description until a null command entry is found
for ( uint8_t cmd = 0; CLIDict[dict][cmd].name != 0; cmd++ )
dPrintStrs(" \033[35m", CLIDict[dict][cmd].name, "\033[0m");
// Determine number of spaces to tab by the length of the command and TabAlign
- uint8_t padLength = CLIEntryTabAlign - lenStr( CLIDict[dict][cmd].name );
+ uint8_t padLength = CLIEntryTabAlign - lenStr( (char*)CLIDict[dict][cmd].name );
while ( padLength-- > 0 )
print(" ");
- dPrintStrNL( CLIDict[dict][cmd].description );
+ _print( CLIDict[dict][cmd].description ); // This print is required by AVR (flash)
+ print( NL );
}
}
}
print( NL );
print( " \033[1mRevision:\033[0m " CLI_Revision NL );
print( " \033[1mBranch:\033[0m " CLI_Branch NL );
- print( " \033[1mTree Status:\033[0m " CLI_ModifiedStatus NL );
+ print( " \033[1mTree Status:\033[0m " CLI_ModifiedStatus CLI_ModifiedFiles NL );
print( " \033[1mRepo Origin:\033[0m " CLI_RepoOrigin NL );
print( " \033[1mCommit Date:\033[0m " CLI_CommitDate NL );
print( " \033[1mCommit Author:\033[0m " CLI_CommitAuthor NL );