Coder Social home page Coder Social logo

Comments (5)

pcottle avatar pcottle commented on April 26, 2024

It would also make more sense because a unix tool should try to do one thing well. I think with this in mind, it would even make sense to have two utilities that could together work as a path picker : the first one which does only the conversion from an output to a list of filenames, the second one which gives an UI to select one or more elements from a list.

Yeah, this has come up a bunch internally and externally. I'm a huge fan of the unix philosophy but I actually think a lot of the value of PathPicker is added by being a "one-stop shop" for everything you need to do with paths. Had we gone more unixy we would either have just:

  1. built the parsing of files and outputted those, or
  2. built the UI selector and worked with any kind of input

But neither of these would have been that great. With 1) developers would still have to do awkward xargs things (or put the command in a subshell like $(ls -l | fpp) which I find annoying). With 2) the input would require a lot of prep with regexes and sed to get into an acceptable format for selection (think of all the work git diff or git diff --stat requires)

so we had to go into brave new territory and do a very non-unixy thing here, but I think it ended up really striking a perfect spot between utility and simplicity.

from pathpicker.

pcottle avatar pcottle commented on April 26, 2024

Anyways, I think it'd be quite easy to fork this project and refactor it to just output the list of files (basically remove the $PYTHONCMD "$BASEDIR/src/choose.py" < /dev/tty line and simply print the list out from python), but I don't think this is something we can support easily since. Let me know if you need pointers on the fork though! Who knows, maybe the fork would become more popular one day :P

from pathpicker.

edi9999 avatar edi9999 commented on April 26, 2024

Hi, If I do the following:

function doProgram {
  # process input from pipe and store as pickled file
  $PYTHONCMD "$BASEDIR/src/processInput.py"
  # now close stdin and choose input...
  exec 0<&-
  # $PYTHONCMD "$BASEDIR/src/choose.py" < /dev/tty
  # execute the output bash script
  # sh ~/.fpp/.fpp.sh < /dev/tty
  cat ~/.fpp/.pickle
}

I don't get the list of filenames as a result. Where can I get the list of the possible files ?

Here is what I get with ls | /.fpp

(dp0
I0
ccopy_reg
_reconstructor
p1
(cformat
SimpleLine
p2
c__builtin__
object
p3
Ntp4
Rp5
(dp6
S'index'
p7
I0
sS'line'
p8
S'assets\n'
p9
sbsI1
g1
(cformat
LineMatch
p10
g3
Ntp11
Rp12
(dp13
g7
I1
sS'end'
p14
I15
sS'hovered'
p15
I00
sS'selected'
p16
I00
sS'start'
p17
I0
sS'num'
p18
I0
sS'file'
p19
S'./CONTRIBUTING.md'
p20
sS'originalFile'
p21
S'CONTRIBUTING.md'
p22
sS'group'
p23
S'CONTRIBUTING.md'
p24
sg8
S'CONTRIBUTING.md\n'
p25
sbsI2
g1
(g2
g3
Ntp26
Rp27
(dp28
g7
I2
sg8
S'fpp\n'
p29
sbsI3
g1
(g10
g3
Ntp30
Rp31
(dp32
g7
I3
sg14
I6
sg15
I00
sg16
I00
sg17
I0
sg18
I0
sg19
S'./fpp.rb'
p33
sg21
S'fpp.rb'
p34
sg23
S'fpp.rb'
p35
sg8
S'fpp.rb\n'
p36
sbsI4
g1
(g10
g3
Ntp37
Rp38
(dp39
g7
I4
sg14
I10
sg15
I00
sg16
I00
sg17
I0
sg18
I0
sg19
S'./index.html'
p40
sg21
S'index.html'
p41
sg23
S'index.html'
p42
sg8
S'index.html\n'
p43
sbsI5
g1
(g2
g3
Ntp44
Rp45
(dp46
g7
I5
sg8
S'LICENSE\n'
p47
sbsI6
g1
(g2
g3
Ntp48
Rp49
(dp50
g7
I6
sg8
S'PATENTS\n'
p51
sbsI7
g1
(g10
g3
Ntp52
Rp53
(dp54
g7
I7
sg14
I9
sg15
I00
sg16
I00
sg17
I0
sg18
I0
sg19
S'./README.md'
p55
sg21
S'README.md'
p56
sg23
S'README.md'
p57
sg8
S'README.md\n'
p58
sbsI8
g1
(g2
g3
Ntp59
Rp60
(dp61
g7
I8
sg8
S'scripts\n'
p62
sbsI9
g1
(g2
g3
Ntp63
Rp64
(dp65
g7
I9
sg8
S'src\n'
p66
sbs.% 

from pathpicker.

edi9999 avatar edi9999 commented on April 26, 2024

Found how to make it work now, I will be releasing a fork

from pathpicker.

pcottle avatar pcottle commented on April 26, 2024

Yeah the issue with cat ~/.fpp/.pickle is that those are pickled bytes from python, not plaintext. Sounds like you figured it out but heres a simple way to print out all the files from the pickled state:

[pcottle:~/Dropbox (Facebook)/wip/PathPicker/src:master]$ python
Python 2.7.6 (default, Sep  9 2014, 15:04:36) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import format
>>> import pickle
>>> fileHandle = open('/Users/pcottle/.fpp/.pickle', 'rb')
>>> lineObjs = pickle.load(fileHandle)
>>> matches = [lineObj for i, lineObj in lineObjs.items() if not lineObj.isSimple()]
>>> for match in matches:
...   print match.getFile()
... 
/Users/pcottle/Dropbox (Facebook)/wip/PathPicker/assets/favicon.ico
/Users/pcottle/Dropbox (Facebook)/wip/PathPicker/assets/fpp-favicon.ico
/Users/pcottle/Dropbox (Facebook)/wip/PathPicker/assets/[email protected]
/Users/pcottle/Dropbox (Facebook)/wip/PathPicker/assets/launch_page.css
./index.html
/Users/pcottle/Dropbox (Facebook)/wip/PathPicker/scripts/buildAndTest.sh
/Users/pcottle/Dropbox (Facebook)/wip/PathPicker/scripts/makeDist.sh
/Users/pcottle/Dropbox (Facebook)/wip/PathPicker/src/colorPrinter.py
/Users/pcottle/Dropbox (Facebook)/wip/PathPicker/src/format.py
/Users/pcottle/Dropbox (Facebook)/wip/PathPicker/src/formattedText.py
/Users/pcottle/Dropbox (Facebook)/wip/PathPicker/src/processInput.py
/Users/pcottle/Dropbox (Facebook)/wip/PathPicker/src/screenControl.py
/Users/pcottle/Dropbox (Facebook)/wip/PathPicker/src/test.py

from pathpicker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.