CLI "using" command -- how does it work?

I think I don't understand what CLI's "using" command is supposed to do. I hoped it would allow me to stop typing "include <myscript.ash>" in my CLI ash commands while testing out bits and pieces of my scripts. But it doesn't seem to do so.

(I did manage to figure out how to un-use, though: clear the global preference commandLineNamespace.)

Example:
myscript.ash:
Code:
int myfunc(int a)
{ return a + 1; }

On the CLI:
Code:
> ash myfunc(1)

Function 'myfunc( int )' undefined ()
Returned: void

> ash import <myscript.ash> myfunc(1);

Returned: 2

> using myscript.ash

int myfunc( int a )

Script verification complete.

> ash myfunc(1)

Function 'myfunc( int )' undefined (myscript.ash)
Returned: void

Is this just not what using is supposed to do? In that case, what is it supposed to do? I await enlightenment!

(It's not a bother if that's not what it is supposed to do, obviously, but it makes me curious.)
 

jasonharper

Developer
I've never used "using" myself, but I believe it just makes the functions in the script available as CLI commands. The "namespace" command will list them.
 
Hey, that's pretty neat. I didn't know Mafia was capable of translating ash to cli, although I guess I should have guessed from the way you can call scripts with the first argument on the cli...
Code:
> using myscript.ash

int myfunc( int a )

Script verification complete.

> namespace

myscript.ash
int myfunc( int a )

> myfunc(1)

Unable to invoke myfunc(1)

> myfunc 1

Returned: 2

So it doesn't put the ash function in the namespace as an ash function, but as a cli-style function. Thanks for the tip, Jason!
 

zarqon

Well-known member
I am always "using" ZLib. Then if I need to resist a given element, I just type "resist" in the CLI. Or if I want my best +item familiar I can type "best_fam items". It's quite handy.
 
Top