Using Cobra CLI in HTTP services

Hey everyone, I have a question that has been bugging me for some time now and have yet to find a satisfactory answer. Hopefully, someone can shed some light here:

I see that in many REST apps, for example, people are using the cobra library. I’m a bit confuzzled by this since in essence that’s a CLI library and in my mind, there’s no connection between CLI and a backend HTTP service for instance. For instance, in Java, I haven’t seen a similar pattern. What am I missing here? Why the need for the CLI?

What is your question? “Why is everyone writing command line interfaces to web services?”

Yup, exactly. Why is this the pattern here? Is there a reason for this?

Command line interfaces to web services are easy to automate/script. I’m not sure if it’s specific to Go; I don’t see it as much with C#, but there are plenty of Python scripts that do the same.

I’m not sure I completely understand what you mean by “easy to automate/script”. Could you expand on that?

I was looking at this article which explains that cobra is being used for passing envars as command line args: Is this why we are using cobra?

I misunderstood your initial post. I missed the word “backend” and I thought you were asking about creating client REST apps with command line interfaces. Now I’m not sure what you mean about there being no connection between the CLI and a backend HTTP service because for *nix, I think it’s extremely common to write services as command line interfaces. If not as a command line application, how would you run a web application server? With a GUI?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.