1
0
Fork 0
mirror of https://github.com/Luzifer/password.git synced 2024-11-09 18:00:03 +00:00

Rebuilt workflow for better design and auto-update

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2017-09-22 17:38:08 +02:00
parent 3d8964f818
commit 28eccb5743
Signed by: luzifer
GPG key ID: DC2729FDD34BE99E
11 changed files with 82 additions and 104 deletions

3
.gitignore vendored
View file

@ -1 +1,4 @@
password
dist
password_darwin_amd64
PasswordGenerator.alfredworkflow

3
.gitmodules vendored Normal file
View file

@ -0,0 +1,3 @@
[submodule "alfred-workflow/lib"]
path = alfred-workflow/lib
url = https://github.com/deanishe/alfred-workflow.git

View file

@ -16,6 +16,13 @@ publish:
bash golang.sh
workflow:
cp password_darwin_amd64 password
zip -9 -j PasswordGenerator.alfredworkflow alfred-workflow/* password
mkdir -p dist
cp -r password_darwin_amd64 \
alfred-workflow/exec.py \
alfred-workflow/icon.png \
alfred-workflow/info.plist \
alfred-workflow/lib/workflow \
dist
echo -n $(shell git describe --tags --exact-match) > dist/version
cd dist && zip -r -9 ../PasswordGenerator.alfredworkflow *
github-release upload --user luzifer --repo password --tag $(shell git describe --tags --exact-match) --name PasswordGenerator.alfredworkflow --file PasswordGenerator.alfredworkflow

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

View file

@ -1,9 +0,0 @@
# 1.2.0 / 2017-09-22
* Update password utility from github
* Stripping newlines from the password
* Updated password to v.1.2.2
* Updated password tool
* Prevent generation of passwords with long duration
* Migrated to Luzifer/password backed password generation
* Added README

View file

@ -1,5 +0,0 @@
compress:
curl -sSLfo ./password https://github.com/Luzifer/password/releases/download/v1.4.0/password_darwin_amd64
chmod +x ./password
rm -rf *.pyc PasswordGenerator.alfredworkflow /tmp/password_master_darwin-amd64.zip /tmp/password
zip -9 PasswordGenerator.alfredworkflow * -x PasswordGenerator.alfredworkflow Makefile

View file

@ -1,11 +0,0 @@
# Alfred2 Password Generator
## Installation
* Ensure your Alfred 2 have the Powerpack enabled
* Download [PasswordGenerator.alfredworkflow](https://github.com/Luzifer/alfred-pwdgen/blob/master/PasswordGenerator.alfredworkflow?raw=true)
* Open downloaded file - the workflow will install itself
## Patches
Please don't republish this workflow but fork it and send me a pull request for your changes. I'll republish the workflow at it's current locations.

45
alfred-workflow/exec.py Normal file
View file

@ -0,0 +1,45 @@
# encoding: utf-8
import subprocess
import sys
from workflow import Workflow, ICON_WEB, web
def main(wf):
password_length = 20
use_special = False
if len(wf.args):
for arg in wf.args[0].split():
if arg.isdigit():
password_length = int(arg)
elif arg == 's':
use_special = True
if password_length < 5 or password_length > 256:
wf.add_item(title="Password length out of bounds",
subtitle="Please use a reasonable password length between 5 and 256")
wf.send_feedback()
return 1
command = ["./password_darwin_amd64", "get", "-l", str(password_length)]
if use_special:
command.append("-s")
result = subprocess.check_output(command).strip()
wf.add_item(title=result, arg=result)
wf.send_feedback()
return 0
if __name__ == "__main__":
wf = Workflow(update_settings={
'github_slug': 'Luzifer/password',
})
if wf.update_available:
# Download new version and tell Alfred to install it
wf.start_update()
sys.exit(wf.run(main))

View file

@ -1,47 +0,0 @@
#author: Peter Okma
import xml.etree.ElementTree as et
class Feedback():
"""Feeback used by Alfred Script Filter
Usage:
fb = Feedback()
fb.add_item('Hello', 'World')
fb.add_item('Foo', 'Bar')
print fb
"""
def __init__(self):
self.feedback = et.Element('items')
def __repr__(self):
"""XML representation used by Alfred
Returns:
XML string
"""
return et.tostring(self.feedback)
def add_item(self, title, subtitle="", arg="", valid="yes", autocomplete="", icon="icon.png"):
"""
Add item to alfred Feedback
Args:
title(str): the title displayed by Alfred
Keyword Args:
subtitle(str): the subtitle displayed by Alfred
arg(str): the value returned by alfred when item is selected
valid(str): whether or not the entry can be selected in Alfred to trigger an action
autcomplete(str): the text to be inserted if an invalid item is selected. This is only used if 'valid' is 'no'
icon(str): filename of icon that Alfred will display
"""
item = et.SubElement(self.feedback, 'item', uid=str(len(self.feedback)),
arg=arg, valid=valid, autocomplete=autocomplete)
_title = et.SubElement(item, 'title')
_title.text = title
_sub = et.SubElement(item, 'subtitle')
_sub.text = subtitle
_icon = et.SubElement(item, 'icon')
_icon.text = icon

View file

@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>bundleid</key>
<string>me.knut.pwd</string>
<string>io.luzifer.pwd</string>
<key>category</key>
<string>Tools</string>
<key>connections</key>
@ -17,6 +17,8 @@
<integer>0</integer>
<key>modifiersubtext</key>
<string></string>
<key>vitoclose</key>
<false/>
</dict>
</array>
</dict>
@ -37,17 +39,23 @@
<false/>
<key>clipboardtext</key>
<string>{query}</string>
<key>transient</key>
<false/>
</dict>
<key>type</key>
<string>alfred.workflow.output.clipboard</string>
<key>uid</key>
<string>F417810A-4CC7-4844-9B6E-DA2D6B40543C</string>
<key>version</key>
<integer>0</integer>
<integer>2</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>alfredfiltersresults</key>
<false/>
<key>argumenttrimmode</key>
<integer>0</integer>
<key>argumenttype</key>
<integer>1</integer>
<key>escaping</key>
@ -65,38 +73,17 @@
<key>runningsubtext</key>
<string>Generating password...</string>
<key>script</key>
<string>import subprocess, sys
from feedback import Feedback
password_length = 20
use_special = False
for arg in '{query}'.split():
if arg.isdigit():
password_length = int(arg)
elif arg == 's':
use_special = True
if password_length &lt; 5 or password_length &gt; 128:
fb = Feedback()
fb.add_item(title="Password length out of bounds", subtitle="Please use a reasonable password length between 5 and 128")
print fb
sys.exit(1)
command = ["./password", "get", "-l", str(password_length)]
if use_special:
command.append("-s")
result = subprocess.check_output(command).strip()
fb = Feedback()
fb.add_item(title=result, arg=result)
print fb</string>
<string>python exec.py "$1"</string>
<key>scriptargtype</key>
<integer>1</integer>
<key>scriptfile</key>
<string></string>
<key>subtext</key>
<string>Generates a secure password with &lt;n&gt; length</string>
<key>title</key>
<string>Password Generator</string>
<key>type</key>
<integer>3</integer>
<integer>0</integer>
<key>withspace</key>
<true/>
</dict>
@ -105,7 +92,7 @@ print fb</string>
<key>uid</key>
<string>F8CBCF9B-3B33-400E-B6AD-6B8500938BA4</string>
<key>version</key>
<integer>0</integer>
<integer>2</integer>
</dict>
</array>
<key>readme</key>
@ -114,11 +101,15 @@ print fb</string>
<dict>
<key>F417810A-4CC7-4844-9B6E-DA2D6B40543C</key>
<dict>
<key>xpos</key>
<integer>700</integer>
<key>ypos</key>
<real>170</real>
</dict>
<key>F8CBCF9B-3B33-400E-B6AD-6B8500938BA4</key>
<dict>
<key>xpos</key>
<integer>300</integer>
<key>ypos</key>
<real>170</real>
</dict>

1
alfred-workflow/lib Submodule

@ -0,0 +1 @@
Subproject commit 39241c12cff55dd94cd001c32de2e319a71a6e66