From: Shohei Yoshida <syohex@gmail.com>
To: zsh-workers@zsh.org
Subject: Re: [PATCH 1/4] Update system_profiler completion
Date: Sun, 27 Aug 2023 16:02:16 +0900 [thread overview]
Message-ID: <CAFX6MOOYuavc80q1GYAodeSy8_OMvopkm2oheN7DGajTe5WL6g@mail.gmail.com> (raw)
In-Reply-To: <CAFX6MOP7rbZ=zt3mxF34=wxvHf8e+zAF_iczSdjB4ZpqvMP7wQ@mail.gmail.com>
[-- Attachment #1.1: Type: text/plain, Size: 1543 bytes --]
attached fixed version.
On Fri, Aug 25, 2023 at 2:24 PM Shohei Yoshida <syohex@gmail.com> wrote:
>
>
> On Fri, Aug 25, 2023 at 1:56 PM Jun T <takimoto-j@kba.biglobe.ne.jp>
> wrote:
>
>>
>> # TODO: Should this be static? Calling `system_profiler -listDataTypes`
>> takes
>> # about 0.07-0.08 secs on my machine. Does this list ever change (between
>> # different versions of OS X)?
>> _data_types=( SP{AirPort,Applications,Audio,...(snip)...,WWAN}DataType )
>> # the dynamic alternative is:
>> #_data_types=( ${${(f)"$(_call_program path system_profiler
>> -listDataTypes 2>/dev/null)"}[2,-1]} )
>>
>> At least on macOS Ventura (the latest), "system_profiler -listDataTypes"
>> gives somewhat different list of data types. And I think the time
>> required by this command is negligible (I can't notice any delay).
>> So isn't it better to use the 'dynamic alternative' in the above comment?
>>
>
> I think the dynamic alternative is better if possible.
>
> --
> Shohei YOSHIDA(syohex@gmail.com)
> <http://b.hatena.ne.jp/entry/https://mail.google.com/_/scs/mail-static/_/js/k=gmail.main.ja.tLQrNXCHmdo.O/m=m_i,t,it/am=nBHH5b_7g8gZ7tIn1f7977tLmp39J3_3JgBC2Amo_5v9P4jWA_ug_FA/rt=h/d=1/t=zcms/rs=AItRSTNJwrjV1i8LKqdsHFfbx47Tnlb-Bw>
>
--
Shohei YOSHIDA(syohex@gmail.com)
<http://b.hatena.ne.jp/entry/https://mail.google.com/_/scs/mail-static/_/js/k=gmail.main.ja.tLQrNXCHmdo.O/m=m_i,t,it/am=nBHH5b_7g8gZ7tIn1f7977tLmp39J3_3JgBC2Amo_5v9P4jWA_ug_FA/rt=h/d=1/t=zcms/rs=AItRSTNJwrjV1i8LKqdsHFfbx47Tnlb-Bw>
[-- Attachment #1.2: Type: text/html, Size: 3267 bytes --]
[-- Attachment #2: 0001-Update-system_profiler-completion.patch --]
[-- Type: application/octet-stream, Size: 2327 bytes --]
From eb3683b889ff2420bb5a3ad5fe2509ddc236a2b7 Mon Sep 17 00:00:00 2001
From: Shohei YOSHIDA <syohex@gmail.com>
Date: Sun, 27 Aug 2023 15:58:26 +0900
Subject: [PATCH] Update system_profiler completion
- add new option completions
- fix timout completion that takes seconds
- generate data types dynamically
---
Completion/Darwin/Command/_system_profiler | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/Completion/Darwin/Command/_system_profiler b/Completion/Darwin/Command/_system_profiler
index fe197579d..0fd8b473b 100644
--- a/Completion/Darwin/Command/_system_profiler
+++ b/Completion/Darwin/Command/_system_profiler
@@ -4,17 +4,13 @@ typeset -A opt_args
local context state state_descr line
local -a _data_types
-# TODO: Should this be static? Calling `system_profiler -listDataTypes` takes
-# about 0.07-0.08 secs on my machine. Does this list ever change (between
-# different versions of OS X)?
-_data_types=( SP{AirPort,Applications,Audio,Bluetooth,Camera,CardReader,Component,ConfigurationProfile,DeveloperTools,Diagnostics,DisabledSoftware,DiscBurning,Displays,Ethernet,Extensions,FibreChannel,FireWire,Firewall,Fonts,Frameworks,Hardware,HardwareRAID,InstallHistory,Logs,ManagedClient,Memory,Network,NetworkLocation,NetworkVolume,PCI,ParallelATA,ParallelSCSI,Power,PrefPane,Printers,PrintersSoftware,SAS,SPI,SerialATA,Software,StartupItem,Storage,SyncServices,Thunderbolt,USB,UniversalAccess,WWAN}DataType )
-# the dynamic alternative is:
-#_data_types=( ${${(f)"$(_call_program path system_profiler -listDataTypes 2>/dev/null)"}[2,-1]} )
+_data_types=( ${${(f)"$(_call_program data-types system_profiler -listDataTypes 2>/dev/null)"}[2,-1]} )
_arguments \
'(- *)-usage' \
'(- *)-listDataTypes[lists the available datatypes]' \
- '(-listDataTypes -usage)-xml[generate xml output]' \
+ '(-listDataTypes -usage -json)-xml[generate xml output]' \
+ '(-listDataTypes -usage -xml)-json[generate json output]' \
'(-listDataTypes -usage)-detailLevel[level of detail for the report]:detail level:(mini basic full)' \
- '(-listDataTypes -usage)-timeout+[maximum time to wait in seconds]' \
+ '(-listDataTypes -usage)-timeout+[maximum time to wait in seconds(0 means no timeout)]:timeout seconds' \
'(-listDataTypes -usage)*:data type:'"($_data_types)"
--
2.42.0
next prev parent reply other threads:[~2023-08-27 7:02 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-23 4:00 [PATCH 0/4] Update macOS command completions Shohei YOSHIDA
2023-08-23 4:00 ` [PATCH 1/4] Update system_profiler completion Shohei YOSHIDA
2023-08-25 4:56 ` Jun T
2023-08-25 5:24 ` Shohei Yoshida
2023-08-27 7:02 ` Shohei Yoshida [this message]
2023-08-25 5:11 ` Jun T
2023-08-23 4:00 ` [PATCH 2/4] Update sw_vers completion Shohei YOSHIDA
2023-08-25 5:01 ` Jun T
2023-08-25 5:29 ` Shohei Yoshida
2023-08-27 6:53 ` Shohei Yoshida
2023-08-23 4:00 ` [PATCH 3/4] Update otool completion Shohei YOSHIDA
2023-08-25 15:16 ` Jun. T
[not found] ` <CAFX6MONwMeWWVmUScwqq1zUiHhebF6+fhi3kvDk1pP=VR7y_oQ@mail.gmail.com>
[not found] ` <F45E2407-3AFA-4925-A247-98013FB3EEAF@kba.biglobe.ne.jp>
2023-08-28 2:32 ` Shohei Yoshida
2023-08-28 4:02 ` Jun T
2023-08-23 4:00 ` [PATCH 4/4] Update open completion Shohei YOSHIDA
2023-08-25 16:07 ` Jun. T
2023-08-27 7:18 ` Shohei Yoshida
[not found] ` <CAH+w=7Z3AKE4Z3EKN7j9Qh+0UPzJgWjibJ7LmqFQ5xN+QSr5Sw@mail.gmail.com>
2023-08-28 1:53 ` Jun. T
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAFX6MOOYuavc80q1GYAodeSy8_OMvopkm2oheN7DGajTe5WL6g@mail.gmail.com \
--to=syohex@gmail.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).