var k=Object.defineProperty;var u=Object.getOwnPropertySymbols;var w=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable;var m=(t,i,a)=>i in t?k(t,i,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[i]=a,h=(t,i)=>{for(var a in i||(i={}))w.call(i,a)&&m(t,a,i[a]);if(u)for(var a of u(i))O.call(i,a)&&m(t,a,i[a]);return t};var g=(t,i,a)=>new Promise((c,o)=>{var d=s=>{try{l(a.next(s))}catch(n){o(n)}},p=s=>{try{l(a.throw(s))}catch(n){o(n)}},l=s=>s.done?c(s.value):Promise.resolve(s.value).then(d,p);l((a=a.apply(t,i)).next())});var P=()=>t=>t,y=[{name:"-p",description:"Prompt for password"},{name:"-u",description:"Authenticate as user",args:{name:"user",description:"User to authenticate as"}},{name:"-P",description:"Authenticate with password",args:{name:"password",description:"Password to authenticate with"}},{name:"-f",description:"Targeted local node database file path",args:{name:"file",description:"File path"}},{name:"-raw",description:"Don't strip off prefix from DirectoryService API constants"},{name:"-plist",description:"Print out record(s) or attribute(s) in XML plist format"},{name:"-url",description:"Print record attribute values in URL-style encoding"},{name:"-q",description:"Quiet - no interactive prompt"}],x=new Set(y.filter(t=>t.args!==void 0).flatMap(t=>t.name)),b={trigger:"/",getQueryTerm:"/",custom:(t,i)=>g(void 0,null,function*(){let a=t[t.length-1];if(a==="")return[];let c=t.indexOf("dscl"),o;for(let s=c+1;s<t.length;s++){let n=t[s];if(n.startsWith("-"))continue;let v=t[s-1];if(!x.has(v)){o=n;break}}let d=a.lastIndexOf("/"),p=a.slice(0,d<0?0:d),{stdout:l}=yield i({command:"dscl",args:[o,"-list",p!=null?p:"/"]});return l.trim().split(`
`).map(s=>({name:s,icon:"\u{1F4C1}",priority:s[s.lastIndexOf("/")+1]==="_"?49:50}))})},e=P()({path:{name:"path",description:"Path to the record",generators:b},key:{name:"key",description:"Directory Service record attribute type"},keys:{name:"keys",description:"Directory Service record attribute type",isVariadic:!0},plistPath:{name:"plist path",description:"Path to the plist file"},valueIndex:{name:"value index",description:"Value index of the key"},val:{name:"val",description:"Value of the key"},vals:{name:"vals",description:"Value of the key",isVariadic:!0},oldVal:{name:"old val",description:"Old value of the key"},newVal:{name:"new val",description:"New value of the key"}}),r=(t,i)=>h(h({},e[t]),i),f={name:"dscl",subcommands:[{name:["read","-read"],description:"Prints a directory",args:[r("path",{isOptional:!0}),r("keys",{isOptional:!0})]},{name:["readall","-readall"],description:"Prints all the records of a given type",args:[r("path",{isOptional:!0}),r("keys",{isOptional:!0})]},{name:["readpl","-readpl"],description:"Prints the contents of plist_path",args:[e.path,e.key,e.plistPath]},{name:["readpli","-readpli"],description:"Prints the contents of plist_path for the plist at value_index of the key",args:[e.path,e.key,e.valueIndex,e.plistPath]},{name:["list","-list","ls","-ls"],description:"Lists the subdirectories of the given directory",args:[e.path,r("key",{isOptional:!0})]},{name:["search","-search"],description:"Searches for records that match a pattern",args:[e.path,e.key,e.val]},{name:["create","-create","mk","-mk"],description:"Creates a new record",args:[e.path,r("key",{isOptional:!0}),r("vals",{isOptional:!0})]},{name:["createpl","-createpl"],description:"Creates a string, or array of strings at plist_path",args:[e.path,e.key,e.plistPath,e.val,r("vals",{isOptional:!0})]},{name:["createpli","-createpli"],description:"Creates a string, or array of strings at plist_path for the plist at value_index of the key",args:[e.path,e.key,e.valueIndex,e.plistPath,e.val,r("vals",{isOptional:!0})]},{name:["append","-append"],description:"Appends one or more values to a property in a given record",args:[e.path,e.key,e.vals]},{name:["merge","-merge"],description:"Appends one or more values to a property in a given directory if the property does not already have those values",args:[e.path,e.key,e.vals]},{name:["delete","-delete","rm","-rm"],description:"Delete a directory, property, or value",args:[e.path,r("key",{isOptional:!0}),r("vals",{isOptional:!0})]},{name:["deletepl","-deletepl"],description:"Deletes a value in a plist",args:[e.path,e.key,e.plistPath,r("vals",{isOptional:!0})]},{name:["deletepli","-deletepli"],description:"Deletes a value for the plist at value_index of the key",args:[e.path,e.key,e.valueIndex,e.plistPath,r("vals",{isOptional:!0})]},{name:["change","-change"],description:"Replaces the given old value in the list of values of the given key with the new value in the specified record",args:[e.path,e.key,e.oldVal,e.newVal]},{name:["changei","-changei"],description:"Replaces the value at the given index in the list of values of the given key with the new value in the specified record",args:[e.path,e.key,e.valueIndex,e.newVal]},{name:["diff","-diff"],description:"Compares the data from path1 and path2 looking at the specified keys (or all if no keys are specified)",args:[e.path,e.path,r("keys",{isOptional:!0})]},{name:["passwd","-passwd"],description:"Changes the password of a user",args:[e.path,{name:"new password",description:"New password of the user",isOptional:!0}]}]},S={name:"dscl",description:"Directory Service command line utility",subcommands:f.subcommands,options:y,args:{name:"datasource",suggestions:[".","..","localhost","localonly"],isOptional:!0,loadSpec:f}},I=S;export{I as default};
