Get_elem() getting called twice with CLI show command and with NETCONF its getting executed properly once

Hi ,

We have a requirement, where we should have show & NETCONF support to fetch the data.

e.g, CLI > show next-free-id

O/P:

next-free-id 1234

Code snip for both CLI & netconf:

    pd->get_elem = get_free_id;
    pd->get_next = NULL;
    pd->exists_optional =  NULL;
    pd->get_object = NULL;
    pd->num_instances = NULL;
pd->get_object = NULL;

So when we execute it via CLI get_elem() is getting called twice.
Hence we getting o/p not as 1234 , its 1236… if executed again it will print 1238 so on.
Same if we execute from netconf we getting proper o/p like 1234, 1235, 1236 etc.

So can you please help us , how to fix the show command execution properly like of netconf… making get_elem() once when show command getting executed from CLI/.