CLI in web based applications

I was recently asked to do a prototype for migrating some, well, lets say not very recent user interfaces to a more web based view on them. The first test was to just make sure that a web based application could perform fast enough and we didn't need to go swing. For the record, I'm not a swing fan because of all the layout finagling and I sure don't like GWT doing all my work for me. Call me a purist or an idiot, your call.

I check out what the users want and come up with a nice thin app using JQuery on the front end communicating via REST services responding with JSON for the datasets. Pretty standard stuff. Nothing too revolutionary there. If you're not using REST, I'd recommend it but I can get on that soapbox later. What was interesting was the request that these workers prefer to use keyboard shortcuts. In essence, I was asked to make a web based application that didn't use a mouse. Pretty interesting and different than usual.

I toss together this prototype and demo it - first suggestion was could I make it so there was just a text box interface where users could type in shortcuts and then use key combinations to drive functionality.

The solution I ended up with uses the hotkeys plugin for jQuery -
It is crazy easy to use, here is binding the f4 key to execute whatever is typed in the text window:

$(document).bind('keydown', 'f4', function(){ executeCLI();});

function executeCLI()
var cliString = $("#prs_cli").val().trim();

//Process cliString, call more functions, etc

Its crazy simple to bind functions then to key combinations. You can even bind key combinations, i.e.

$(document).bind('keydown', 'ctrl+c', function(){ executeCopy();});

Why would anyone do this? At first I asked the same question. The mouse is there, use it. But then I started using the CLI interface for the web. Think about how faster you, the maven, are with CLI? Think about the experienced user being able to interact with web apps this way. Pretty cool and effective stuff.

So check out hotkeys and maybe think about some CLIs for your super users of your web apps.


Cygwin + Interpreters(Jline) + Carriage return = solved!

I love cygwin. Not only is having every a bash shell and unix utility on windows awesome(grep, less, tail, awk, cut, pipe, sed, du, df, ls, ln, curl, sort, head, vi, X-Server, etc...) but using rxvt or xterm as a replacement to windows cmd window is awesome.

However when I use some command line interpreters such as a groovy shell, maven cli, spring roo, and others, my carriage return doesn't work. When I hit enter, the cursor goes to the next line but the command is not executed. This has been bothering me for months and yesterday I finally found the answer.

The core of the problem is with JLine, a command line API that many Java based interpreters use. Jline queries the environment to see what OS you are running and uses that for the expected end of line input. Because the OS is windows but the terminal is xterm, cygwin (rxvt at least) will not send the command Jline is expecting to signal end of line. Therefore, you can't actually execute anything in the interpreter.

So after searching for a solution over and over I finally stumbled upon this issue. Thank god for JIRA! It ultimately led me to this Jline defect.

So in order to save you a lot of trouble, all you have to do is add the following to your jvm args:

If you are doing this for maven CLI, then you need to add the -D argument to your MAVEN_OPTS because Maven will execute the process for you.

I didn't need to use the stty commands as recommended but I only fixed my maven-cli plugin (which is awesome btw). Maybe someone could explain what the stty commands are for and when or why you'd need them.

So hopefully this will save some cygwin users some time and frustration.


What we do know

To the contrary of my previous post, I thought I would say what we do know. Without further ado, What we do know (an abbreviated list...well, hopefully)

  • We know that its hard to keep an architecture simple
  • We know that if you have a solution or tool in place that has a 'large impact for replacement' - boy oh boy, did you either eff up the use of the tool or did you purchase one sh1tburger of a tool to start with
  • We know that if you want your employees / team / co-workers to be engaged and highly productive, you have to allow them to be engaged and highly productive.
Perhaps I will dive into this in more detail in future posts.


What we don't know

You know those conversations you have in your head that always come across sounding so awesome? Well, here is the start of one that I had in my head, and a conversation that I want to have but you know, it might not be the best for work....

Command-and-control-director: 'You don't know my world. I've worked for 10 years to make my world just right, you can't change it. You don't know the implications of the changes you are suggesting and how it would impact the company.'

Me: 'You're absolutely right. I have no ides of the implications. And on top of that, I have no desire to know or even hear the implications.'

By no means do I claim that this is an original thought - sometimes it is prior knowledge that blinds us from seeing and understanding other opportunities. Today, for example, my 3-year old daughter wanted to take off her shoes and socks and go stand on some wet rocks in this rock pond at an arboretum. It was 50 degrees out and breezy so I tried to convince her otherwise. But she was persistent and I let her. She loved it, she played in there happily skipping around for 30 minutes.

The pond water was heated.

I was basing my decision on prior knowledge. It was cold out and breezy, therefore this shallow water will be cold. Did I stick my hand in the water to test it? No, I knew it was cold.

The pond was heated.

And so we see this in large organizations now. People of high rank that have been around for a long time - they have solved the problems of their world. They have all the experience and the knowledge. When someone challenges them - well, that challenger couldn't possibly understand the cost of such a decision and if they had, they wouldn't be making such outlandish comments. What complicates this situation more is when this type of mentality is tolerated. It leads to a stagnant flow and ultimately to a company unable to change.

Change is difficult for anyone, let alone a company or a large company at that. At the Agile 2009 conference this year in Chicago, JB Rainsberger had an amazingly profound session where he talked about his lessons learned in 10 years doing XP. There he talked about the Satir Interaction model. In my best attempt to abbreviate it and not minimize its impact, it is understanding the other persons perception while you are interacting with them. Pretty hard to do, I suggest everyone try it.

The example I gave at the start of this post is real. How should one deal with this scenario? Yeah, the way I mentioned sounded awesome in my head. But I'm not convinced it is the best. Perhaps it is the difficulty of having that director's perception, but I really believe that he wants empirical data. Change is hard for him to value because he doesn't have metrics and historic examples in his world that he can call up...and that's fine. That's what he needs, and ultimately you have to believe that he wants to do what is best. But that's what he needs and what he knows. Given that, how should I address the situation? Probably with no response. Keep doing the skunk works, show the value in the change until it is too big to ignore, and then help him think it was his idea.

In the theme of this blog set - that man is not a maven. But that shouldn't stop the mavens from progressing along. They just need a better salesperson. And if you can't find that salesperson at your current location, then you find it somewhere else.

In summary - sometimes the best thing to know is that you don't want to know. You just might find out the pond is heated.