Is it possible to use command syntax in static methods or packaged functions?

I am building an API that I would like to use from command prompt frequently. The API has several static methods that have one string input. I would like to be able to call these methods from the prompt using command syntax, eg:
MyClass.myMethod arg1
or, alternatively, I would like to be able to do the same, but via functions in a package, eg:
MyPackage.wrapperForMyMethod arg1
However, neither of these seem to work. I am wondering if there is any special way to enable command syntax in either of these cases.

4 Comments

I asked the same question recently (sorry I didn't see yours before), and just got an answer back from Mathworks. Basically they said they don't support using command syntax on fully qualified package or class signatures but "it might be considered for future releases".
At the moment, if you have a package, you can do:
import MyPackage.wrapperForMyMethod % or import MyPackage.*
wrapperForMyMethod arg1
Unfortunately, there is no work-around for static class methods.
Why would you want this? Using the function syntax allows many code helping tools to work properly. What would be the benefits of this syntax?
Rik,
Same reason there exists a command syntax to begin with; convenience.
cd('to/my/path')
vs
cd to/my/path
Duc Le,
No problem. Just happy you answered my question!

Sign in to comment.

Answers (0)

Products

Release

R2018a

Asked:

on 28 Dec 2021

Commented:

on 6 Feb 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!