Idea: S9y CLI tool

Discussion corner for Developers of Serendipity.
mattsches
Regular
Posts: 440
Joined: Sat Nov 05, 2005 9:35 pm
Location: Wiesbaden, Germany
Contact:

Idea: S9y CLI tool

Post by mattsches »

I find myself writing CLI tools for many of my projects lately. People write them for popular OSS projects, too, for example: And the list could go on ...

Usually, these tools start with a basic set of commands: printing out the currently installed version number; installing an instance of the project (with interaction on the shell); running tests; creating a new user; etc. Later, some of them turn into fully featured administration tools.

Personally, I'm pretty happy with the Symfony2 Console component that makes writing CLI commands really easy. But other options exist, e.g. Laravel's Artisan.

Actually, I wanted to write a simple tool first, so I could show it to you before posting here, but I was busy with other things. A project like this could (start to) exist outside of S9y, no problem with that. So:

Do you think a CLI tool would make sense for S9y?
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: Idea: S9y CLI tool

Post by yellowled »

mattsches wrote:Do you think a CLI tool would make sense for S9y?
I'm pretty sure at least the Uberspace users among us would love that. Also, we seem to have a rather high percentage of users with shell access, so why not? I also don't see why this should not be an official s9y project right from the start …?

YL
mattsches
Regular
Posts: 440
Joined: Sat Nov 05, 2005 9:35 pm
Location: Wiesbaden, Germany
Contact:

Re: Idea: S9y CLI tool

Post by mattsches »

Ok, I just tried to write a very basic console command based on the Symfony2 Console component. I wanted to print out the currently installed S9y version and the title of the blog.

It's pretty impossible to bootstrap the blog application from the command line because it expects server and request globals and tons of other stuff. Would have been nice to simply require_once('serendipity_config.inc.php') and read all the info from there, but this won't work, of course.

But I could parse the file and find the version number with the help of some regexes. However, the actual version number is stored in serendipity_config_local.inc.php, and because this file is readable only for the web server user (www-data in my case), it cannot be read from the shell command. Bummer.

Database connection, on the other hand, was straightforward using the Doctrine2 DBAL, so I can now read the blog title and a lot of other info directly from the DB and print it out on the console:

Code: Select all

$ php console.php version
Version: 2.0-alpha1
Blog title: Serendipity 2.0 Dev Blog
I guess this console tool will start its life as a simple diagnosis and info helper :wink:

It's really not more than a proof of concept now, but I will go ahead and push it to GitHub once it has some basic functionality.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Idea: S9y CLI tool

Post by garvinhicking »

Hi!

Really? Usually 'include serendipity_config.inc.php' should actually work, what errors do you get?! (Of course this requires you to be a user that has read access to serendipity_config_local.inc.php...

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
mattsches
Regular
Posts: 440
Joined: Sat Nov 05, 2005 9:35 pm
Location: Wiesbaden, Germany
Contact:

Re: Idea: S9y CLI tool

Post by mattsches »

I thought about it, and you're probably right :wink:

Whoever is using the CLI tool must be root or at least must have read rights to serendipity_config_local.inc.php. Otherwise it just doesn't make sense.

Thanks for the heads up, Garvin.

PS: Yup, works!
artodeto
Regular
Posts: 12
Joined: Sat Jul 30, 2011 12:07 am
Contact:

Re: Idea: S9y CLI tool

Post by artodeto »

Hi, is there already something available on an open source and forkable plattform?

Currently, i don't know what the tool could be good for, but since i like to work with symfony 2 console component, i would love to have a look on the current state and get influenced by ;-).
mattsches
Regular
Posts: 440
Joined: Sat Nov 05, 2005 9:35 pm
Location: Wiesbaden, Germany
Contact:

Re: Idea: S9y CLI tool

Post by mattsches »

artodeto wrote:Hi, is there already something available on an open source and forkable plattform?

Currently, i don't know what the tool could be good for, but since i like to work with symfony 2 console component, i would love to have a look on the current state and get influenced by ;-).
Great, you're welcome to look at it and also to contribute once it's released! We're currently in a kind of closed alpha testing phase, but I would very much like to release it next weekend or so. Keep an eye on the S9y Github account.

The tool won't have a lot of functionality right from the start, but it should be easy to add more and meaningful commands quickly. I'm looking forward to ideas, proposals, or even pull requests. In a way, it's learning project for me, too.

I would also love to give it a clever/catchy name, right now it's called "s9ytool", but that's a bit boring imho. Suggestions anyone?
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Idea: S9y CLI tool

Post by Timbalu »

mattsches wrote:I would also love to give it a clever/catchy name, right now it's called "s9ytool", but that's a bit boring imho. Suggestions anyone?
http://de.wikipedia.org/wiki/Unterwelt_ ... Mythologie
How about Styx, in Orpheus and Eurydice...? :)
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: Idea: S9y CLI tool

Post by yellowled »

mattsches wrote:I would also love to give it a clever/catchy name, right now it's called "s9ytool", but that's a bit boring imho. Suggestions anyone?
Given the origin of Serendipity, how about Rufus?

YL
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Idea: S9y CLI tool

Post by garvinhicking »

Guys, we need to have some tool or platform called "Metatron".

Just sayin'.
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: Idea: S9y CLI tool

Post by yellowled »

Oh, take Metatron! (I hereby reserve at least Bartleby, Loki and Azrael for new templates.) :)

YL
mattsches
Regular
Posts: 440
Joined: Sat Nov 05, 2005 9:35 pm
Location: Wiesbaden, Germany
Contact:

Re: Idea: S9y CLI tool

Post by mattsches »

I must admit that I was also toying with the idea of calling it "Metatron" (after looking for inspiration here) :lol:

The more I think about it the more I actually like it!

PS: Concerning "Bartleby" - look who mentioned it first ;) We could also use it as a code name for the 2.0 release ... do we have code names for releases? Shouldn't we?
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: Idea: S9y CLI tool

Post by yellowled »

mattsches wrote:We could also use it as a code name for the 2.0 release ... do we have code names for releases? Shouldn't we?
With the current naming scheme, we'll run out of code names very quickly. :)

YL
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Idea: S9y CLI tool

Post by Timbalu »

Though I really like all these code name suggestions here, I have to admit I NEVER took inspiration for Serendipity from a comedy film...., since I seem to be some kind out of time..., linking this far more into the history, back to Horace Walpole and him inspired by the "The Three Princes of Serendip"... :wink:
This is far more Serendipity than a film can ever be...!
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: Idea: S9y CLI tool

Post by yellowled »

While we're at it, I have to admit that Dogma is actually one of the very few flicks by Kevin Smith which I don't like. :mrgreen:

YL
Post Reply