Representation of commands of the command line interface in code: implementation of the "database", where the query and result are obtained from the CLI's own commands

Problem area:

I am working on a new version of a Java application that connects via SSH to its own Linux-based command-line platform (CLI). Everything on the platform that I want to do or know is accessible only with the CLI and stdout commands.

One of the available commands gets information from the internal database (without using SQL) with the following command arguments: query, subquery, result format, and sort preference.

The considered solution:

I would like to provide an API that encapsulates SSH / CLI low-level behavior details and achieves the following:

  • Eliminate the current method that is prone to errors in the embedded query strings (currently it is very prone to typos).
  • Make the API intuitive since the current request and command formats are usually not understood.
  • Provide a consistent error and answers to the result.

I am considering creating query and response builders at the lowest level that implements SSH / CLI behavior; then create a level above it that allows you to retrieve attributes from the platform by attribute categories (compared to database tables).

Question:

I rummaged through my book The Gang of Four and other resources to find sensible approaches that could be the starting point; also looking at syntax tree information.

"SQL ", , - - , , . , , CLI .

+3

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


All Articles