# Building a command hierarchy from RPCs in CLI

**URL:** https://dmap-community.ductus.global/t/building-a-command-hierarchy-from-rpcs-in-cli/1939
**Category:** Other Northbound Interfaces
**Created:** [June 8, 2018, 3:00pm UTC](https://dmap-community.ductus.global/t/building-a-command-hierarchy-from-rpcs-in-cli/1939 "2018-06-08T15:00:59Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![sszabolcs](https://avatars.discourse-cdn.com/v4/letter/s/96bed5/32.png) [@sszabolcs](https://dmap-community.ductus.global/u/sszabolcs)
#### Post date: [June 8, 2018, 3:01pm UTC](https://dmap-community.ductus.global/t/building-a-command-hierarchy-from-rpcs-in-cli/1939/1 "2018-06-08T15:01:00Z")

</div>

Hi,

What is the best way to create a command hierarchy in the CLI?  
I want to use RPC-s defined in my YANG modules. By default they are populated into the request command in a flat structure. I would like to create a tree like structure:  
request group-1 RPC-1  
request group-1 RPC-3  
request group-2 RPC-2

Thanks,  
Szabolcs

---

<div class="post-metadata">

### Author: ![cohult](https://yyz2.discourse-cdn.com/flex010/user_avatar/dmap-community.ductus.global/cohult/32/221_2.png) [@cohult](https://dmap-community.ductus.global/u/cohult)
#### Post date: [June 12, 2018, 7:24am UTC](https://dmap-community.ductus.global/t/building-a-command-hierarchy-from-rpcs-in-cli/1939/2 "2018-06-12T07:24:14Z")

</div>

Hi,

An [RPCs statement](https://tools.ietf.org/html/rfc7950#section-7.14) must, according to the YANG RFCs (e.g. RFC7950), be placed at the top level in the module.

You may be looking for the [YANG 1.1 action statement](https://tools.ietf.org/html/rfc7950#section-7.15) (or for YANG 1.0 the tailf:action extension)?

---

<div class="post-metadata">

### Author: ![sszabolcs](https://avatars.discourse-cdn.com/v4/letter/s/96bed5/32.png) [@sszabolcs](https://dmap-community.ductus.global/u/sszabolcs)
#### Post date: [June 12, 2018, 8:53am UTC](https://dmap-community.ductus.global/t/building-a-command-hierarchy-from-rpcs-in-cli/1939/3 "2018-06-12T08:53:22Z")

</div>

Hi,

I want to create a standard NETCONF interface (with YANG 1.0), so I can’t use tailf specific extensions that changes how the NETCONF interface works.  
It is not a problem on the NETCONF interface that the RPCs are not grouped. I just want to group them on the CLI interface. I found the cli-mount-point extension, but it is not well documented.

Thanks,  
Szabolcs

---

<div class="post-metadata">

### Author: ![cohult](https://yyz2.discourse-cdn.com/flex010/user_avatar/dmap-community.ductus.global/cohult/32/221_2.png) [@cohult](https://dmap-community.ductus.global/u/cohult)
#### Post date: [June 12, 2018, 12:18pm UTC](https://dmap-community.ductus.global/t/building-a-command-hierarchy-from-rpcs-in-cli/1939/4 "2018-06-12T12:18:18Z")

</div>

Hi,

In that case I suggest you use the clispec to display the commands in the CLI.

An example similar to as if you were using an actionpoint in a RPC:

```xml
<cmd name="RPC-1" mount="request group-1">
    <info>Do something</info>
    <help>Do something using an rpc action</help>
    <callback>
        <capi>
            <cmdpoint>my-action-point</cmdpoint>
        </capi>
    </callback>
</cmd>

```

See clispec(5) man page and the ConfD examples e.g under examples.confd/cli/c\_cli

You can hide your YANG rpc from showing up in the CLI/JSON-RPC:

```auto
rpc RPC-1 {
      tailf:hidden dont-show-in-cli;
      tailf:actionpoint my-action-point;
}

```

You can use the same actionpoint for the YANG RPC and the clispec command. Example:

```auto
/* register the action handler callback */
struct confd_action_cbs acb;
memset(&acb, 0, sizeof(acb));
strcpy(acb.actionpoint, "my-action-point");
acb.init = init_action;
acb.action = do_action;
acb.abort = abort_action;
acb.command = do_action; // <-- Your CLI command variant

```
