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 件のコメント

Duc Le
Duc Le 2022 年 2 月 5 日
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.
Rik
Rik 2022 年 2 月 5 日
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
Dave White
Dave White 2022 年 2 月 6 日
Duc Le,
No problem. Just happy you answered my question!

サインインしてコメントする。

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeStartup and Shutdown についてさらに検索

製品

リリース

R2018a

質問済み:

2021 年 12 月 28 日

コメント済み:

2022 年 2 月 6 日

Community Treasure Hunt

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

Start Hunting!

Translated by