server/ash friendly inventory management Question

The attached script is designed to be an ash wrapper around cli item management functions using maps. I've run into a question about working with my mall store though.

The CLI command instructions from Kolmafia Basic Scripting
mallsell <itemname> [price] [limit]
(mallsell mr. accessory 5,000,000 0)

Places the given item in your store in the mall. The user must specify the item which will be sold in the mall, the price, and the desired limit. A limit of 0 equates to no limit at all. Note that the user cannot specify how many of the item will be placed in the mall.

Most cli item management functions accept a comma separated list of items but the example shows commas being used in the price area which seems to me like it would interfere with the separation of a list of items. Does mallsell accept multiple items at the same time, or do I need to write my own functions to handle multiple?
 

Attachments

  • display_stash_closet_multi.ash
    1.2 KB · Views: 38

holatuwol

Developer
I could have it accept a list, but I need a format for it. :\ The problem is for everything else, there's one quantity, but for store management, there's 1-3.
 
; is the command seperator
, in that command is used in the price field for appearance reasons

it might take some work, but

mallsell clover 3,000 0, bat wing 250 0
where a comma then a space is the list separator, and a comma followed by anything else is considered to be part of a number or whatever.

I think this is actually what most people end up doing for readability when using other list type cli commands anyway. So far every time I have requested someone switch from the ash commands to the server friendly cli_execute version I have written comma space into it (when I ask someone to change their script, normally I write the whole change for them). Based on both those facts if the change wound up affecting all cli list functions I don't think it would cause many (if any) already written scripts to fail. Also I think the format would be simple enough to understand.
 

holatuwol

Developer
How about ... adding more symbols to the command? I have no issues with supporting backwards compatibility for a single entry, but having it easier to read would be nice? Maybe:

mallsell * red snowcone, * blue snowcone @ 200, green snowcone @ 1000/1

Shorthand is nice, but I think separating the numbers with other things will help a little?
 
Is that saying all red and blue snowcones at 200 each and 1 green snowcone at 1000 each and limit 1 per day, or is that showing 3 possible parameter lineups?

"1000/1" I can see confusion coming in the future because 1000/2=500 and 1000/3=333.33 If that is the limit per day, my preference would be 1000L1 or maybe 1000:1 or 1000#1 or even 1000~1. I actually think 1000~1 is the one I would be most comfortable with.

Any way that you should decide to implement adding multiple items to the mall will be fine with me though because I will actually use the command from an ASH cli_execute command. I will also ask others to use it from their ash scripts as shown here as needed. I just think it is great that you are considering it as a viable plan!
 
Code:
mallsell * banana @ 0 limit 5, * cold hi mein @ 0 limit 3, 23 spring @ 100 limit 0, 0 ten leaf clover @3000 limit 0

This seems fine to me. The shortened "L" option seems fine also. It would seem to me that making the Limit field optional would make things easier on those who primarily use cli scripts. If omitted, kolmafia could assume 0 (or the current limit if it wouldn't cause excessive server hits) That would leave:

Code:
mallsell * banana @ 0, * cold hi mein @ 0, 23 spring @ 100, 0 ten leaf clover @3800
 
hmm, something as simple as that...maybe it should throw an error, or maybe kolmafia could handle that possibility. I did that twice in one post...headdesk!
 

holatuwol

Developer
See, the thing with abbreviations for limit is that they really only matter if people *really* want to be able to set a limit from the command line without having to type alot, and it's not buried in a script.

I'm aiming for readability of CLI scripts (and ASH scripts, for that matter, but that may be a lost cause given the flexibility ^_~), so ... unless there's a specific reason L is prefered to limit (other than less typing ... for something that may not have to be even typed that often, particularly if it's in a script, where you're copy-pasting anyway), I'm probably sticking with the whole word.
Or allowing comma-delimited versions of the shorthand. In the event that you REALLY want to minimize typing.
 
[quote author=Alexander Daychilde link=topic=817.msg3979#msg3979 date=1174539862]
I, for one, forgot we were discussing scripting, as most of what I do is basically use gCLI.
[/quote]

And the funny thing is in the end, if this is implemented, I will actually be invoking it from an ash script even though we are talking about a cli function.

Something like:

Code:
Record Mall_set
  {
  int Price;
  int Limit;
  int Quantity;
  };

typedef MallSet [item] mallitemset;

//maxint has become my universal ash replacement for * in cli
int maxint = 2147483647;

void mall_dump(mallitemset set)
  {
  string temp_command = "mallsell ";
  foreach key in set
    {
    if(set[key].Quantity == maxint)
      {
      temp_command = temp_command + "* " + key + " @ " + set[key].Price + " limit " + set[key].Limit + ", ";
      }
      else
      {
      temp_command = temp_command + set[key].quantity + " " + key + " @ " + set[key].Price + " limit " + set[key].Limit + ", ";
      }
    }
  if(temp_command != command)
    {
    //trim last camma space pair
    temp_command = substring(temp_command, 0, last_index_of(temp_command, ", " ) - 1);
    cli_execute(temp_command);
    }
  }

Which will build the cli command using the proposed new abilities of Kolmafia to make Item transfers to the mall more server friendly. I figure that we are using the cli version of the command simply because all ash functions are 1 item at a time versus other cli functions can handle multiple items at once.

Effectively what I am saying is my opinion about the actual format of the final command should be considered, but not held as highly as those who may actually work with it more than once. I will be doing some minor touch ups to the code above to fit the final format, and fix any mistakes, then because of "import" I will probably not see the code again for months unless I am showing it to someone else for some reason. The actual usage of it will become a daily thing almost instantly. (Whispers: I already have some scripts ready to be switched over to import the above, and it may be as simple as uncomment the new comment out the old.) ;D
 
[quote author=holatuwol link=topic=839.msg4069#msg4069 date=1175814983]
Revision: 3409
Comma-delimited mallsell lists
[/quote]


Just want to verify: Is the following from above (corrected a typo) the correct format?
[quote author=efilnikufecin link=topic=817.msg3972#msg3972 date=1174496250]
Code:
mallsell * banana @ 0 limit 5, * cold hi mein @ 0 limit 3, 23 spring @ 100 limit 0, 0 ten leaf clover @ 3000 limit 0
[/quote]

Oh and thanks for adding this! I'm going to love using it!
 
Top