When writing a package to share on SSC, is it possible (advisable?) to create an abbreviated command syntax?
For example, with official Stata commands like -describe-, we can run -d- , -de-, -des-, -desc-... etc to invoke the same command. (Without any reason to) I always assumed that program syntax had some sort of capitalization convention that would allow for abbreviations (similar to how options are abbreviated) so that programs would look like:
to enable abbreviations by the first 4 letters (in the scenario above). However, after looking through my adopath today, I finally realized that there are actually separate ado-files for each potential abbreviation. The abbreviated versions call the main program like:
Now to the question. If I wanted to create my own program called -describe2- (for example, I am not actually writing one called this or related to -describe- in any way), could (should?) I submit to SSC the following adofiles to be downloaded with the package for my hypothetical command -describe2- ?
This seems inadvisable, but I'd like to be able to invoke the program I'm writing with both the long command name (which is a better descriptor of the program's purpose) and an abbreviated form (even if it was just two forms: -des2- and -describe2-). Are there better ways to approach this or other examples?
The only solution (workaround) I can think of is to put the -describe2- version on SSC and then write an internal program called -d2- or whatever that calls -describe2- ( but that will require some rewriting of do-files for me and my colleagues who have been using the abbreviated form of the program internally at my organization.)
What about having the main ado-file write the sub-ado files if the user chooses to have them on their system. That is, there would be an option called 'writeabbrev' where if the user ran this at any point:
The program would -file write- a new .ado file and put it in the ado-path which contains syntax similar to the code for desc.ado from above. This would activate the ability to use the abbreviation from that point forward (but the first time a user encountered an abbreviated version they would get an uninformative error because desc2 wouldnt exist ). Other thoughts or ideas ?
Thanks!
For example, with official Stata commands like -describe-, we can run -d- , -de-, -des-, -desc-... etc to invoke the same command. (Without any reason to) I always assumed that program syntax had some sort of capitalization convention that would allow for abbreviations (similar to how options are abbreviated) so that programs would look like:
Code:
program define DESCribe ...
Code:
*! version 1.0.0 27may2004 program d /* version intentionally omitted */ local version : di "version " string(_caller()) ":" `version' describe `0' end
Code:
d2.ado de2.ado ... describe2.ado ??
The only solution (workaround) I can think of is to put the -describe2- version on SSC and then write an internal program called -d2- or whatever that calls -describe2- ( but that will require some rewriting of do-files for me and my colleagues who have been using the abbreviated form of the program internally at my organization.)
What about having the main ado-file write the sub-ado files if the user chooses to have them on their system. That is, there would be an option called 'writeabbrev' where if the user ran this at any point:
Code:
describe2, writeabbrev
Thanks!
Comment