zli5t / ShellQDB

A quote database implemented entirely in shell.
2 stars 0 forks source link

quote data #4

Closed ethanjli closed 14 years ago

ethanjli commented 14 years ago

i.e. getqf 5 would return the quote flag (u|a|h) of quote 5 and getqs 5 would return the score of quote 5 (by the way, should we rename setqscore to setqs to be consistent with the rest of the name abbreviations?)

I'm not that familiar with sed/awk/etc., so I don't really know how to do the whole "get the (first|second) value between two double-colons" thing.

zli5t commented 14 years ago

I don't think we really EVER need this. It seems pretty useless, IMO. Give me an example when this would come in handy.

ethanjli commented 14 years ago

Okay, I'm not sure about getqf. Regarding getqs: I think there would be more clarity for such things as a web interface (or rss interface, etc.) if we had something like the following way of getting quote data

getq 5 | blahblahblah to get the contents of quote #5
getqs 5 to get the score of quote #5
getqf 5 to get the flag of quote #5 (again, if, for some reason, we/somebody decide(s) to adapt the quote flag for some other uses in the future which we haven't thought of, it'll be easy to handle).

Thus, it's easy to put the quote information in any format: we get the individual bits of data for each part of a quote entry, and it's very easy to do whatever we want with it.

(What are other options for retrieving the score of a specific quote?)

ethanjli commented 14 years ago

Also, we could use getqs to retrieve the score of a quote we want to change the score of, so we don't need to use awk or $qtempfile for setqs (I think).

zli5t commented 14 years ago

lietk12: when would you ever need only 1 of these things? Like, JUST the score, JUST the flag? If you havent noticed, outq/html gets all of these in a perfectly acceptable, easily modifiable format. It formats multiple quotes at once in whatever order you shove them into it. Thats the whole point.

the code for getqs would be: awk -F:: '$1=='$1'{print $2}' <$qfile <--change $2 to whatever field you want. Seriously, thats it. If you want, put it in, i just dont see any particular use for it.

see, the whole point of using awk was so it would be “easy to put the quote information in any format: we get the individual bits of data for each part of a quote entry, and it's very easy to do whatever we want with it.” Which is totally true already. For an example, again, see outq/html.

ethanjli commented 14 years ago

Oh, I see. I thought it was more complex (because I didn't understand how the awk command was formed); I did a preliminary scan over man awk, and that command makes much more sense now.

Yeah, it seems like a dumb idea to put awk -F:: '$1=='$1'{print $2}' <$qfile as its own script.