<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>CLI command with parameter</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/24514/cli-command-with-parameter</link><description>Hello, 
 I would like to have something like this: 
 ROOT_COMMAND SubCommand CustomParameter 
 Example: 
 DeviceName Set ExampleDeviceName 
 Where CustomParameter can be a string or hex value, that I would like to get and store in non volatile memory</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 21 Aug 2017 11:34:31 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/24514/cli-command-with-parameter" /><item><title>RE: CLI command with parameter</title><link>https://devzone.nordicsemi.com/thread/96511?ContentTypeID=1</link><pubDate>Mon, 21 Aug 2017 11:34:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3d9b0923-3527-4c25-9caa-d23ac45e9837</guid><dc:creator>jakub</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Yes it is possible and quite easy with CLI.&lt;/p&gt;
&lt;p&gt;I would recommend to implement handlers for both commands: DeviceName and Set.
DeviceName can have a simple handler to print command help - please refer to CLI examples.
Actual handler shall be implemented within Set command. To make it even more easy I would recommend you to implement 2 subcommands: SetString and SetHex.&lt;/p&gt;
&lt;p&gt;I would do it like that:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;NRF_CLI_CREATE_STATIC_SUBCMD_SET(m_sub_device_name)
{
    NRF_CLI_CMD(SetHex,    NULL, &amp;quot;Your subcommand help string.&amp;quot;,  cmd_set_hex),
    NRF_CLI_CMD(SetString, NULL, &amp;quot;Your subcommand help string.&amp;quot;,  cmd_set_string),
    NRF_CLI_SUBCMD_SET_END
};
NRF_CLI_CMD_REGISTER(DeviceName,
                     &amp;amp;m_sub_device_name,
                     &amp;quot;Your command help string.&amp;quot;,
                     cmd_device_name);
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>