Giter Site home page Giter Site logo

goreplace's Introduction

goreplace's People

Contributors

a-h avatar alexwhitman avatar maqroll avatar piranha avatar sarum9in avatar tcard avatar vigneshsarma avatar vsolovyov avatar waldyrious avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

goreplace's Issues

Search entries are duplicated sometimes

 % gr secure

app/states/signin.jade
2:input(placeholder="Password", secure, key="password")

app/states/signup.jade
2:input(placeholder="Password", secure, key="password")

css/elements.less
84:    &[secure] {

Have no idea what it depends on, but I faced this bug three times at least (using gr daily for few weeks).

Output on windows is unreadable

And making it output colors means cgo, which means I won't be able to cross-compile.

Simpler solution for now is just removing colors when writing something on Windows.

Нормализация отступов в поисковой выдаче

Допустим есть такой код:

  # где-то в 9 строке:
  foo

  # где-то в 185 строке:
  foo
    foo

gr по фразе foo найдет три строки (9, 185 и 186) и напечатает их с сохранением отсутпов, но номер строки 9 занимает 1 символ, а 185-186 — три, тем самым визуально добавляя еще по два пробела к 185 и 186 относительно 9:

9:  foo
185:  foo
186:    foo

Злит неимоверно :) Как насчет такого?

9  :  foo
185:  foo
186:    foo

Config file

So that you can add some specific files which are tracked by VCS, but which should not be touched. It should be collected recursively (i.e. find one at repo root, one at your homedir, merge them).

Вопрос по используемым регекспам

GoReplace поддерживает в поисковых запросах регэкспы?

Я попробовал искать, результат:

C:\U\e\Projects\m-s\src\blog> gr -c "layouts"
2009-05-18-awesome-nastrojka.markdown
17:    layouts =

2010-11-13-jekyll-hyde.markdown
28:     |-- _layouts
40:<strong>_layouts</strong> - это каталог, содержащий используемые шаблоны страниц. Обычно это два шаблона, использующих язык разметки Liquid.

2013-04-20-jekyll-tags.markdown
35:Теперь в директории `_layouts` создаем файл `tag_page.html`, пример кода данной страницы есть на странице расширения, я же использовал следующий вариант:

C:\U\e\Projects\m-s\src\blog> gr -c "^<"

C:\U\e\Projects\m-s\src\blog> gr -c "^\<"

C:\U\e\Projects\m-s\src\blog> gr -c "^/<"

C:\U\e\Projects\m-s\src\blog>

Первый поиск показал, что есть строка, как минимум одна, которая начинается с символа открытия треугольной скобки. При попытке задать в поиске параметр содержания символа в начале строки получаем нулевой результат.

Выходит в поиске нет возможности использовать регэкспы? Или используется какой-то свой язык?

Подобный же вопрос касается описания программы. Указывается, что используется функции grep и sed. По grep задал вопрос выше, и кстати, проверил запрос, описанный выше, именно в grep, получил массу строк в результате.

sed использует в своем функционале свой собственный язык поиска и замены. Что именно из языка sed было реализовано в GoReplace?

Skipped files list improvements

I would like you to consider adding two things:

  1. Human-friendly display of skipped files size

machine_ _valentin_macbook-pro____projects_evrone_machine_ _zsh_ _153x42_and_category_ids_rb_-__users_valentin_projects_evrone_machine_-_atom

i.e. show 1.2M instead of 1223479

  1. Have the size of skipped files be configurable (either a configuration file or a command line option)

Thanks!

Does not exclude files from .gitignore

~/p/test (master) goreplace
Usage of goreplace 0.4.3:
gr [OPTS] string-to-search

Ignoring patterns from test/.gitignore:
globs: .bundle /db/.sqlite3 /log/ /tmp/* .DS_Store .rbenv-gemsets .powenv /public/uploads/** /public/assets

~/p/test (master) goreplace aws -n
Skipping log/development.log, too big: 38096819
Skipping log/test.log, too big: 395531579
tmp/cache/assets/D5D/A70/sprockets%2Fe8712ded68ed3a8ac1b18ac400244c32
tmp/cache/assets/D6E/0E0/sprockets%2Feaaea015e64217c9ff78f24eba681651
tmp/cache/assets/E2E/9A0/sprockets%2F6fdcccd483dc6dbc7fc31adb80d50668

Goreplace sometimes dies with a traceback

Apparently it started after upgrading to macOS 10.12:

andrey@andreymac ~/work/prophy/prophy> gr 'get_article2tfidf_vector'
Skipping datalib/tests/testdata/sw_ontology.json, too big: 13859118

src/prophy/clusters/article_metrics.py
 79:def get_article2tfidf_vector(article2property: TArticle2Property,
116:        return get_article2tfidf_vector(article2property=article2property,
Skipping src/tests/latex_archives/with_text_and_refs/1203.3562v1, too big: 11284480

failed MSpanList_Insert 0x279c00 0x947226add66d 0x0
fatal error: MSpanList_Insert

goroutine 16 [running]:
runtime.throw(0x22ca1b)
	/usr/local/Cellar/go/1.3.1/libexec/src/pkg/runtime/panic.c:520 +0x69 fp=0xc20807f060 sp=0xc20807f048
runtime.MSpanList_Insert(0x242c28, 0x279c00)
	/usr/local/Cellar/go/1.3.1/libexec/src/pkg/runtime/mheap.c:618 +0x8a fp=0xc20807f088 sp=0xc20807f060
MHeap_FreeLocked(0x23ec20, 0x279c00)
	/usr/local/Cellar/go/1.3.1/libexec/src/pkg/runtime/mheap.c:447 +0x1a6 fp=0xc20807f0c8 sp=0xc20807f088
MHeap_AllocLocked(0x23ec20, 0x156, 0x0)
	/usr/local/Cellar/go/1.3.1/libexec/src/pkg/runtime/mheap.c:257 +0x288 fp=0xc20807f108 sp=0xc20807f0c8
runtime.MHeap_Alloc(0x23ec20, 0x156, 0x10100000000)
	/usr/local/Cellar/go/1.3.1/libexec/src/pkg/runtime/mheap.c:178 +0x7b fp=0xc20807f130 sp=0xc20807f108
largealloc(0xc200000001, 0xc20807f1e0)
	/usr/local/Cellar/go/1.3.1/libexec/src/pkg/runtime/malloc.goc:224 +0xa2 fp=0xc20807f178 sp=0xc20807f130
runtime.mallocgc(0x2aa800, 0x107141, 0x1)
	/usr/local/Cellar/go/1.3.1/libexec/src/pkg/runtime/malloc.goc:169 +0xb6 fp=0xc20807f1e0 sp=0xc20807f178
cnew(0x107140, 0x2aa800, 0x1)
	/usr/local/Cellar/go/1.3.1/libexec/src/pkg/runtime/malloc.goc:836 +0xc1 fp=0xc20807f200 sp=0xc20807f1e0
runtime.cnewarray(0x107140, 0x2aa800)
	/usr/local/Cellar/go/1.3.1/libexec/src/pkg/runtime/malloc.goc:849 +0x3a fp=0xc20807f220 sp=0xc20807f200
makeslice1(0x1000e0, 0x2aa800, 0x2aa800, 0xc20807f280)
	/usr/local/Cellar/go/1.3.1/libexec/src/pkg/runtime/slice.goc:55 +0x4d fp=0xc20807f238 sp=0xc20807f220
runtime.makeslice(0x1000e0, 0x2aa800, 0x2aa800, 0x0, 0x2aa800, 0x2aa800)
	/usr/local/Cellar/go/1.3.1/libexec/src/pkg/runtime/slice.goc:36 +0xb3 fp=0xc20807f268 sp=0xc20807f238
main.(*GRVisitor).GetFileAndContent(0xc208025320, 0xc208036f40, 0x38, 0x283488, 0xc208168230, 0xc208038050, 0x0, 0x0, 0x0)
	/Users/piranha/dev/go/src/goreplace/goreplace.go:235 +0x125 fp=0xc20807f360 sp=0xc20807f268
main.(*GRVisitor).VisitFile(0xc208025320, 0xc208036f40, 0x38, 0x283488, 0xc208168230)
	/Users/piranha/dev/go/src/goreplace/goreplace.go:190 +0x3d9 fp=0xc20807f4b8 sp=0xc20807f360
main.(*GRVisitor).Walk(0xc208025320, 0xc208036f40, 0x38, 0x283488, 0xc208168230, 0x0, 0x0, 0x0, 0x0)
	/Users/piranha/dev/go/src/goreplace/goreplace.go:148 +0x137 fp=0xc20807f4f8 sp=0xc20807f4b8
main.*GRVisitor.Walk·fm(0xc208036f40, 0x38, 0x283488, 0xc208168230, 0x0, 0x0, 0x0, 0x0)
	/Users/piranha/dev/go/src/goreplace/goreplace.go:121 +0x7f fp=0xc20807f548 sp=0xc20807f4f8
path/filepath.walk(0xc208036f40, 0x38, 0x283488, 0xc208168230, 0xc20807fda8, 0x0, 0x0)
	/usr/local/Cellar/go/1.3.1/libexec/src/pkg/path/filepath/path.go:343 +0x8c fp=0xc20807f690 sp=0xc20807f548
path/filepath.walk(0xc208174ae0, 0x2b, 0x283488, 0xc208168410, 0xc20807fda8, 0x0, 0x0)
	/usr/local/Cellar/go/1.3.1/libexec/src/pkg/path/filepath/path.go:368 +0x4f5 fp=0xc20807f7d8 sp=0xc20807f690
path/filepath.walk(0xc2081ba1c0, 0x18, 0x283488, 0xc208168140, 0xc20807fda8, 0x0, 0x0)
	/usr/local/Cellar/go/1.3.1/libexec/src/pkg/path/filepath/path.go:368 +0x4f5 fp=0xc20807f920 sp=0xc20807f7d8
path/filepath.walk(0xc208000d10, 0x9, 0x283488, 0xc208168eb0, 0xc20807fda8, 0x0, 0x0)
	/usr/local/Cellar/go/1.3.1/libexec/src/pkg/path/filepath/path.go:368 +0x4f5 fp=0xc20807fa68 sp=0xc20807f920
path/filepath.walk(0xc2080815d5, 0x3, 0x283488, 0xc20841bcc0, 0xc20807fda8, 0x0, 0x0)
	/usr/local/Cellar/go/1.3.1/libexec/src/pkg/path/filepath/path.go:368 +0x4f5 fp=0xc20807fbb0 sp=0xc20807fa68
path/filepath.walk(0x15bdd0, 0x1, 0x283488, 0xc20801ae60, 0xc20807fda8, 0x0, 0x0)
	/usr/local/Cellar/go/1.3.1/libexec/src/pkg/path/filepath/path.go:368 +0x4f5 fp=0xc20807fcf8 sp=0xc20807fbb0
path/filepath.Walk(0x15bdd0, 0x1, 0xc20807fda8, 0x0, 0x0)
	/usr/local/Cellar/go/1.3.1/libexec/src/pkg/path/filepath/path.go:390 +0xe5 fp=0xc20807fd60 sp=0xc20807fcf8
main.searchFiles(0xc2080840a0, 0x283538, 0xc208054680, 0x283628, 0xc20801ac30)
	/Users/piranha/dev/go/src/goreplace/goreplace.go:121 +0xda fp=0xc20807fdc0 sp=0xc20807fd60
main.main()
	/Users/piranha/dev/go/src/goreplace/goreplace.go:101 +0x69a fp=0xc20807ff50 sp=0xc20807fdc0
runtime.main()
	/usr/local/Cellar/go/1.3.1/libexec/src/pkg/runtime/proc.c:247 +0x11a fp=0xc20807ffa8 sp=0xc20807ff50
runtime.goexit()
	/usr/local/Cellar/go/1.3.1/libexec/src/pkg/runtime/proc.c:1445 fp=0xc20807ffb0 sp=0xc20807ffa8
created by _rt0_go
	/usr/local/Cellar/go/1.3.1/libexec/src/pkg/runtime/asm_amd64.s:97 +0x120

goroutine 19 [finalizer wait]:
runtime.park(0x1ce00, 0x22f230, 0x22e5e9)
	/usr/local/Cellar/go/1.3.1/libexec/src/pkg/runtime/proc.c:1369 +0x89
runtime.parkunlock(0x22f230, 0x22e5e9)
	/usr/local/Cellar/go/1.3.1/libexec/src/pkg/runtime/proc.c:1385 +0x3b
runfinq()
	/usr/local/Cellar/go/1.3.1/libexec/src/pkg/runtime/mgc0.c:2644 +0xcf
runtime.goexit()
	/usr/local/Cellar/go/1.3.1/libexec/src/pkg/runtime/proc.c:1445
zsh: exit 2     gr 'get_article2tfidf_vector'

Looks like both goreplace 2.3 and 2.4 are affected (haven't tried other versions).

panic: runtime error

I'm seeing the following runtime error:

$ ls -l
total 4
-rw------- 1 501 501 229 Jun 17 12:53 sess_v4ash3jjtkg8nueb2bhbf4ic50
$ gr test
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0 pc=0x44bddc]

goroutine 1 [syscall]:
syscall.Syscall()
    /usr/lib/go/src/pkg/syscall/asm_linux_amd64.s:16 +0x5

The directory is a sub-directory of an sshfs mount point and the user/group 501 is not the sshfs user so gr doesn't have permission to read the file.

To try and replicate I created an unreadable file locally but gr didn't error so I'm not sure specifically what combination of things is required to trigger the error.

I'm running Ubuntu 13.04 64bit, go version 1.1 and goreplace version 1.2.

-r '' does not work

It's impossible to delete stuff, since goopt doesn't recognize empty strings as strings.

[Feature request] Search context

I often use gr to do a quick search but sometimes it would be useful to know the context of what is found by looking at the surrounding lines. Adding something like grep's -A, -B and -C flags would be useful.

nogroup option

A nogroup option would allow clicking on the path:line_number to open the file in terminals that support it.

(NB: ag and pt both have this option with the name nogroup so using the same name would avoid having to remember different names when switching between tools)

"Can't read file" error on a directory

I'm getting an odd error: Can't read file 'CMSADMIN/tinymce3/jscripts/tiny_mce': %!s(MISSING) - It's odd because the path printed is actually a directory, not a file, so I'm not sure why it's trying to be read in the first place in GetFileAndContent().

Feature Request - Echo the files without changing

As of now, go-replace replaces the strings in the files in the current directory, it would be nice to also print out the files without changing them.

For example, this is the current behaviour
go-replace search -r replace

A sed alternative of what I am looking for
cat * | sed 's/search/replace/'

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.