How to create a console application from an existing object-oriented API?

I have:

  • Existing Object Oriented Native API (Non-GUI)
  • GUI application that works with this API

Purpose: To create an additional console application that allows the user to perform a set of workflows (similar to how it is shown in the above graphical interface) by typing commands. This application should be "stateful" - available commands, and their results will depend on previously issued teams.

Problem: I do not want to "reinvent the wheel." Are there existing templates for both creating an application and defining a vocabulary? Currently, it seems to me that the best option would be to write a set of helpers and a command parser from scratch.

PS If my API were in .Net, I would look in the direction of PowerShell, but the API is large and wrapped it in .Net is very laborious.

+3
source share
6 answers

To get started on the command line, do not reinvent the wheel first. There are many options for parsing commands.

Java Commons CLI, , . .NET CLI port.

InfiniteRed , Ruby.

, . . Command " "; Commons Chain . .NET Chain port.

, , . , , , Ruby - . , .

UPDATE: JCommander .

+1

, , Read-Eval-Print (REPL), .

, , , , API.

+3

COM-? PowerShell script COM, WMI .NET; p/invtime runtime script; . , .

-Oisin

+1

.net, , Mono.Options: http://tirania.org/blog/archive/2008/Oct-14.html p >

"Mono.Options - . , , , , ".

+1

API , SIP SWIG, python ipython, , .

, , :

  • /API ( ).
  • Python - , ( ipython).
+1

xOn, com-, "", AddRef "", Release. , . ... .

, , , com addref release.

0

Source: https://habr.com/ru/post/1709607/


All Articles