简体   繁体   English

更好的命令行界面

[英]Better command line interface

I have developed a application which caches multiple packages. 我开发了一个缓存多个包的应用程序。 The CLI interface for this application is as follows 此应用程序的CLI界面如下所示

submit -z pkg1.zip -c pkgChecksum1 -t pkgType1 -s pkgSize1 -z pkg2.zip -c pkgChecksum2 -t pkgType2 -s pkgSize2 

So this submits 2 packages pkg1.zip and pkg2.zip which have checksum pkgChecksum1 and pkgChecksum2 respectively, package type as pkgType1 and pkgType2, and size as pkgSize1 and pkgSize2 respectively. 所以这提交了2个包pkg1.zip和pkg2.zip,它们分别有校验和pkgChecksum1和pkgChecksum2,包类型为pkgType1和pkgType2,大小分别为pkgSize1和pkgSize2。

We also provide XML Based input to the application which is as follows 我们还为应用程序提供了基于XML的输入,如下所示

submit --script an.xml

where an.xml is 其中an.xml是

<?xml version="1.0" encoding="ISO-8859-1"?>
<packages>
<package name="pkg1.zip" checksum="pkgChecksum1" type="pkgType1" size="pkgSize1" />
<package name="pkg2.zip" checksum="pkgChecksum2" type="pkgType2" size="pkgSize2" />
</packages>

This is the functional equivalent of the first CLI method. 这是第一个CLI方法的功能等价物。

We were planning to make this more user friendly, any ideas to improve? 我们计划让这个用户更友好,有什么想法可以改进吗?

Are all the options required? 是否需要所有选项? Or are there defaults for type and size and checksum? 或者是否有类型和大小以及校验和的默认值? If there are no defaults, you could get rid of the tags and just require arguments in groups of four. 如果没有默认值,您可以删除标记,只需要四个一组的参数。

submit pkg1.zip pkg1Cksum pkg1type pkg1sz pkg2.zip pkg2Cksum pkg2type pkg2sz 

Another option in this case is to use the tags, but prompt the user for missing values. 此情况下的另一个选项是使用标记,但会提示用户输入缺失值。

If there are defaults (can the checksum and size be calculated automatically?), allow seletive overrides: 如果存在默认值(可以自动计算校验和和大小吗?),请允许选择性覆盖:

submit pkg1.zip -t pkg1type pkg2.zip -t pkg2type -s pkg2szOverride

Another option that might be helpful is a -a existingCache , which appends to an existing file (or creates it if not present). 另一个可能有用的选项是-a existingCache ,它附加到现有文件(或者如果不存在则创建它)。 This would let the user break it up into several maneagable command lines 这将让用户将其分解为几个可以处理的命令行

   submit -a mycache pkg1.zip -t pkg1type -s pkg1sz
   submit -a mycache pkg2.zip -t pkg2type -s pkg2sz

One more option, based on the comments: 还有一个选项,基于评论:

  submit -x pkg1.zip:2034 0x232D -y pkg2.zip pkg3.zip:123

where -x,-y, etc are flags for the different supported "types". 其中-x,-y等是不同支持的“类型”的标志。 So this line submits pkg1 with size 2034, type X, and a checksum; 所以这一行提交pkg1,大小为2034,类型为X,校验和; pkg2 of type y, no size or checksum specified; y型的pkg2,未指定大小或校验和; and pkg3 of size 123 with no type or checksum specified. 和pkg3的大小为123,没有指定类型或校验和。

You should provide long options along with short option for the various parameters in the CLI. 您应该为CLI中的各种参数提供长选项和短选项。 For example 例如

submit --package pkg1.zip --checksum pkgChecksum1 --type pkgType1 --size pkgSize1 --package  pkg2.zip -checksum pkgChecksum2 --type pkgType2 --size pkgSize2

It's hard to tell what you should do. 很难说你应该做什么。 It depends on who is the target audience of your application. 这取决于谁是您的应用程序的目标受众。 Two possible options: 两种可能的选择:

  1. GUI interface, for users that don't know / are scared of using CLI GUI界面,适用于不知道/害怕使用CLI的用户
  2. Interactive CLI, similar to this: 交互式CLI,类似于:
 Package name: > pkg1.zip Checksum: > pkgChecksum1 Type: pkgType1 

Another option that occurs to me: 我遇到的另一个选择:

submit pkg1.zip:type:2034:0x232D     pkg2.zip:type2:2034:0x232D

I think that the problem is that submit can manage multiple options for each parameter, so adding each of them at once could make the interface simpler. 我认为问题在于提交可以为每个参数管理多个选项,因此一次添加它们可以使界面更简单。 Remebering type, size and chksum for each one should not be difficult. 记住每一个的类型,大小和chksum应该不难。 After all, it seems that all parameters are mandatory. 毕竟,似乎所有参数都是强制性的。 This way, it is not possible to mess the options for one package with the options for the other one. 这样,就不可能将一个包的选项与另一个包的选项混为一谈。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM